From e8b0c5c7cd2a891384870ab76efd47d49bfa5310 Mon Sep 17 00:00:00 2001 From: Martin Raifer Date: Tue, 25 Oct 2022 16:30:26 +0200 Subject: [PATCH] fix leaking of localized strings in combo fields when taginfo is unavailable fixes #9342 and fall back to populate such fields with "static" options if taginfo service is offline --- CHANGELOG.md | 2 ++ modules/ui/fields/combo.js | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3ce77d8d..b16569079 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ _Breaking developer changes, which may affect downstream projects or sites that #### :white_check_mark: Validation #### :bug: Bugfixes * Fix selection of best background source when starting on a zoomed-out view ([#9325]) +* Fix leaking of localized strings in combo fields when taginfo service is unavailable ([#9342]) #### :rocket: Presets * Support tagging schema v5 ([#9320]): * Add new field type `colour` ([schema-builder#38], [#8782]) @@ -57,6 +58,7 @@ _Breaking developer changes, which may affect downstream projects or sites that [#9294]: https://github.com/openstreetmap/iD/issues/9294 [#9320]: https://github.com/openstreetmap/iD/pull/9320 [#9325]: https://github.com/openstreetmap/iD/issues/9325 +[#9342]: https://github.com/openstreetmap/iD/issues/9342 [schema-builder#38]: https://github.com/ideditor/schema-builder/pull/38 # 2.22.0 diff --git a/modules/ui/fields/combo.js b/modules/ui/fields/combo.js index e1bb41d34..4bb9dc175 100644 --- a/modules/ui/fields/combo.js +++ b/modules/ui/fields/combo.js @@ -141,8 +141,8 @@ export function uiFieldCombo(field, context) { if (_showTagInfoSuggestions && services.taginfo) { selection.call(_combobox.fetcher(setTaginfoValues), attachTo); + setStaticValues(); // pre-populate _combobox.data with static values setTaginfoValues('', setPlaceholder); - } else { selection.call(_combobox, attachTo); setStaticValues(setPlaceholder); @@ -189,7 +189,11 @@ export function uiFieldCombo(field, context) { } services.taginfo[fn](params, function(err, data) { - if (err) return; + if (err) { + // if service is unavailable: use static values (if any) + setStaticValues(callback); + return; + } data = data.filter(function(d) { // don't show the fallback value