mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
suppress autocomplete for taginfo results if field has static values
fixes #9898 Fixes a problem that occurs because the order of the field `options` can be in general different from the order returned by taginfo (taginfo sorts by usage, while presets typically are sorted alphabetically), causing different values to be potentially selected for autocomplete values. As the taginfo results typically come in a few moments delayed, this can lead to confusing behaviour. This solves it by just not reattempting an autocomplete using the taginfo results, if a field has static options available.
This commit is contained in:
@@ -230,12 +230,12 @@ export function uiCombobox(context, klass) {
|
||||
// Called whenever the input value is changed (e.g. on typing)
|
||||
function change(doAutoComplete) {
|
||||
if (doAutoComplete === undefined) doAutoComplete = true;
|
||||
fetchComboData(value(), function() {
|
||||
fetchComboData(value(), function(skipAutosuggest) {
|
||||
_selected = null;
|
||||
var val = input.property('value');
|
||||
|
||||
if (_suggestions.length) {
|
||||
if (doAutoComplete && input.property('selectionEnd') === val.length) {
|
||||
if (doAutoComplete && !skipAutosuggest && input.property('selectionEnd') === val.length) {
|
||||
_selected = tryAutocomplete();
|
||||
}
|
||||
|
||||
@@ -319,7 +319,7 @@ export function uiCombobox(context, klass) {
|
||||
function fetchComboData(v, cb) {
|
||||
_cancelFetch = false;
|
||||
|
||||
_fetcher.call(input, v, function(results) {
|
||||
_fetcher.call(input, v, function(results, skipAutosuggest) {
|
||||
// already chose a value, don't overwrite or autocomplete it
|
||||
if (_cancelFetch) return;
|
||||
|
||||
@@ -327,7 +327,7 @@ export function uiCombobox(context, klass) {
|
||||
results.forEach(function(d) { _fetched[d.value] = d; });
|
||||
|
||||
if (cb) {
|
||||
cb();
|
||||
cb(skipAutosuggest);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -194,6 +194,11 @@ export function uiFieldCombo(field, context) {
|
||||
}
|
||||
|
||||
|
||||
function hasStaticValues() {
|
||||
return getOptions().length > 0;
|
||||
}
|
||||
|
||||
|
||||
function setStaticValues(callback, filter) {
|
||||
_comboData = getOptions();
|
||||
|
||||
@@ -209,7 +214,9 @@ export function uiFieldCombo(field, context) {
|
||||
|
||||
function setTaginfoValues(q, callback) {
|
||||
var queryFilter = d => d.value.toLowerCase().includes(q.toLowerCase()) || d.key.toLowerCase().includes(q.toLowerCase());
|
||||
setStaticValues(callback, queryFilter);
|
||||
if (hasStaticValues()) {
|
||||
setStaticValues(callback, queryFilter);
|
||||
}
|
||||
|
||||
var stringsField = field.resolveReference('stringsCrossReference');
|
||||
var fn = _isMulti ? 'multikeys' : 'values';
|
||||
@@ -283,7 +290,7 @@ export function uiFieldCombo(field, context) {
|
||||
_comboData = _comboData.filter(queryFilter);
|
||||
|
||||
_comboData = objectDifference(_comboData, _multiData);
|
||||
if (callback) callback(_comboData);
|
||||
if (callback) callback(_comboData, hasStaticValues());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user