Skip to content

Commit

Permalink
Prevent stale results when first searching presets
Browse files Browse the repository at this point in the history
  • Loading branch information
quincylvania committed Apr 5, 2019
1 parent a054db6 commit 550a4df
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions modules/ui/preset_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,21 @@ export function uiPresetList(context) {
if (geocoder && entity) {
var center = entity.extent(context.graph()).center();
geocoder.countryCode(center, function countryCallback(err, countryCode) {
// get the input value again because it may have changed
var currentValue = search.property('value');

if (!currentValue.length) return;

var results;
if (!err && countryCode) {
countryCode = countryCode.toLowerCase();
results = presets.search(value, geometry, countryCode);
results = presets.search(currentValue, geometry, countryCode);
} else {
results = presets.search(value, geometry);
results = presets.search(currentValue, geometry);
}
message.text(t('inspector.results', {
n: results.collection.length,
search: value
search: currentValue
}));
list.call(drawList, results);
});
Expand Down

0 comments on commit 550a4df

Please sign in to comment.