Skip to content

Commit a35653d

Browse files
committed
use all available option strings when setting value
this fixes where tag values of fields with referenced strings can become corrupted when the sub-field has restricted `options`, and an unavailable option is entered manually into the field. important for openstreetmap/id-tagging-schema#891
1 parent f9aa675 commit a35653d

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ _Breaking developer changes, which may affect downstream projects or sites that
4646
* Fix `multi/many/semiCombo` options for not being selectable immediately after removing them for fields with predefined options
4747
* Fix a bug where the _Add_ input element on comboboxes with a fixed set of allowed options is still hidden after an option of a previously "fully saturated" field is removed
4848
* Fix wrongly flagged "incorrect geometry type" warnings for features with lifecycle-prefixed tags ([#9483], thanks [@biswajit-k])
49+
* Fix corruption of tag values of fields with referenced strings, but restricted `options`, when an unavailable option is entered manually into the field.
4950
#### :earth_asia: Localization
5051
* Send `Accept-Language` header on Nominatim API calls ([#9501], thanks [@k-yle])
5152
* Add Address and Phone Format for India ([#9482], thanks [@biswajit-k])

modules/ui/fields/combo.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export function uiFieldCombo(field, context) {
7373
function tagValue(dval) {
7474
dval = clean(dval || '');
7575

76-
var found = getOptions().find(function(o) {
76+
var found = getOptions(true).find(function(o) {
7777
return o.key && clean(o.value) === dval;
7878
});
7979
if (found) return found.key;
@@ -171,11 +171,17 @@ export function uiFieldCombo(field, context) {
171171
}
172172
}
173173

174-
function getOptions() {
174+
function getOptions(allOptions) {
175175
var stringsField = field.resolveReference('stringsCrossReference');
176176
if (!(field.options || stringsField.options)) return [];
177177

178-
return (field.options || stringsField.options).map(function(v) {
178+
let options;
179+
if (allOptions !== true) {
180+
options = field.options || stringsField.options;
181+
} else {
182+
options = [].concat(field.options, stringsField.options).filter(Boolean);
183+
}
184+
return options.map(function(v) {
179185
const labelId = getLabelId(stringsField, v);
180186
return {
181187
key: v,

0 commit comments

Comments
 (0)