diff --git a/CHANGELOG.md b/CHANGELOG.md index cf1aa3196..10936b6d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ _Breaking developer changes, which may affect downstream projects or sites that #### :tada: New Features #### :sparkles: Usability & Accessibility * Add a preview to colour fields, showing a native colour picker dialog on click ([#8782], thanks [@k-yle]) +* Tag keys of a multi-selection can now also be changed in the tags editor when the tag values differ in the selected features. ([#8836]) #### :scissors: Operations * Split operation now indicates more clearly when multiple ways will be affected and gives a hint how to restrict the operation to a single line ([#8818]) #### :camera: Street-Level @@ -83,6 +84,7 @@ _Breaking developer changes, which may affect downstream projects or sites that [#8817]: https://github.com/openstreetmap/iD/pull/8817 [#8818]: https://github.com/openstreetmap/iD/issues/8818 [#8828]: https://github.com/openstreetmap/iD/pull/8828 +[#8836]: https://github.com/openstreetmap/iD/issues/8836 [@k-yle]: https://github.com/k-yle # 2.20.2 diff --git a/modules/ui/entity_editor.js b/modules/ui/entity_editor.js index 5d4a20697..d8c4203bd 100644 --- a/modules/ui/entity_editor.js +++ b/modules/ui/entity_editor.js @@ -161,7 +161,10 @@ export function uiEntityEditor(context) { for (var k in changed) { if (!k) continue; var v = changed[k]; - if (v !== undefined || tags.hasOwnProperty(k)) { + if (typeof v === 'object') { + // a "key only" tag change + tags[k] = tags[v.oldKey]; + } else if (v !== undefined || tags.hasOwnProperty(k)) { tags[k] = v; } } diff --git a/modules/ui/sections/raw_tag_editor.js b/modules/ui/sections/raw_tag_editor.js index 376ef5221..cc9776073 100644 --- a/modules/ui/sections/raw_tag_editor.js +++ b/modules/ui/sections/raw_tag_editor.js @@ -254,7 +254,7 @@ export function uiSectionRawTagEditor(id, context) { .attr('title', function(d) { return d.key; }) .call(utilGetSetValue, function(d) { return d.key; }) .attr('readonly', function(d) { - return (isReadOnly(d) || (typeof d.value !== 'string')) || null; + return isReadOnly(d) || null; }); items.selectAll('input.value') @@ -488,27 +488,29 @@ export function uiSectionRawTagEditor(id, context) { } - var row = this.parentNode.parentNode; - var inputVal = d3_select(row).selectAll('input.value'); - var vNew = context.cleanTagValue(utilGetSetValue(inputVal)); - _pendingChange = _pendingChange || {}; if (kOld) { + if (kOld === kNew) return; + // a tag key was renamed + _pendingChange[kNew] = _pendingChange[kOld] || { oldKey: kOld }; _pendingChange[kOld] = undefined; + } else { + // a new tag was added + let row = this.parentNode.parentNode; + let inputVal = d3_select(row).selectAll('input.value'); + let vNew = context.cleanTagValue(utilGetSetValue(inputVal)); + _pendingChange[kNew] = vNew; + utilGetSetValue(inputVal, vNew); } - _pendingChange[kNew] = vNew; - // update the ordered key index so this row doesn't change position var existingKeyIndex = _orderedKeys.indexOf(kOld); if (existingKeyIndex !== -1) _orderedKeys[existingKeyIndex] = kNew; d.key = kNew; // update datum to avoid exit/enter on tag update - d.value = vNew; this.value = kNew; - utilGetSetValue(inputVal, vNew); scheduleChange(); }