diff --git a/CHANGELOG.md b/CHANGELOG.md index 41ddcd8bb..5bde57b5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ _Breaking developer changes, which may affect downstream projects or sites that * Properly sort map features with lifecycle prefixes in the _Past/Futures_ features ([#7582]) * Only consider features with either `landuse`, `natural`, `amentiy` or `leisure` tag to be classified as _Landuse_ areas * Fix address field overwriting existing data when switching selected map features under certain circumstances ([#10260]) +* Show `name` field also when only a localized name is present (e.g. only `name:xy`, but not `name`) and the preset does not show the name field by default ([#10323], thanks [@samhoooo]) #### :earth_asia: Localization #### :hourglass: Performance #### :mortar_board: Walkthrough / Help @@ -72,7 +73,9 @@ _Breaking developer changes, which may affect downstream projects or sites that [#10257]: https://github.com/openstreetmap/iD/pull/10257 [#10260]: https://github.com/openstreetmap/iD/issues/10260 [#10302]: https://github.com/openstreetmap/iD/issues/10302 +[#10323]: https://github.com/openstreetmap/iD/issues/10323 [@zbycz]: https://github.com/zbycz +[@samhoooo]: https://github.com/samhoooo # 2.29.0 diff --git a/modules/ui/field.js b/modules/ui/field.js index c7f0f2ca5..ca6932a8f 100644 --- a/modules/ui/field.js +++ b/modules/ui/field.js @@ -8,6 +8,7 @@ import { uiTooltip } from './tooltip'; import { geoExtent } from '../geo/extent'; import { uiFieldHelp } from './field_help'; import { uiFields } from './fields'; +import { LANGUAGE_SUFFIX_REGEX } from './fields/localized'; import { uiTagReference } from './tag_reference'; import { utilRebind, utilUniqueDomId } from '../util'; @@ -97,6 +98,15 @@ export function uiField(context, presetField, entityIDs, options) { } return false; } + if (field.type === 'localized') { + for (let tagKey in _tags) { + // matches for field:, where is a BCP 47 locale code + let match = tagKey.match(LANGUAGE_SUFFIX_REGEX); + if (match && match[1] === field.key && match[2]) { + return true; + } + } + } return _tags[key] !== undefined; }); } diff --git a/modules/ui/fields/localized.js b/modules/ui/fields/localized.js index 8726ce8c5..8d5850e8d 100644 --- a/modules/ui/fields/localized.js +++ b/modules/ui/fields/localized.js @@ -14,6 +14,7 @@ import { uiLengthIndicator } from '../length_indicator'; var _languagesArray = []; +export const LANGUAGE_SUFFIX_REGEX = /^(.*):([a-z]{2,3}(?:-[A-Z][a-z]{3})?(?:-[A-Z]{2})?)$/; export function uiFieldLocalized(field, context) { var dispatch = d3_dispatch('change', 'input'); @@ -127,7 +128,7 @@ export function uiFieldLocalized(field, context) { // matches for field:, where is a BCP 47 locale code // motivation is to avoid matching on similarly formatted tags that are // not for languages, e.g. name:left, name:source, etc. - var m = k.match(/^(.*):([a-z]{2,3}(?:-[A-Z][a-z]{3})?(?:-[A-Z]{2})?)$/); + var m = k.match(LANGUAGE_SUFFIX_REGEX); if (m && m[1] === field.key && m[2]) { var item = { lang: m[2], value: tags[k] }; if (existingLangs.has(item.lang)) {