Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions modules/ui/sections/raw_tag_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,11 @@ export function uiSectionRawTagEditor(id, context) {

var kNew = context.cleanTagKey(this.value.trim());

if (!kNew) {
this.value = kOld;
return;
}

// allow no change if the key should be readonly
if (isReadOnly({ key: kNew })) {
this.value = kOld;
Expand Down Expand Up @@ -542,6 +547,7 @@ export function uiSectionRawTagEditor(id, context) {

function valueChange(d3_event, d) {
if (isReadOnly(d)) return;
if (!d.key) return;

// exit if this is a multiselection and no value was entered
if (Array.isArray(d.value) && !this.value) return;
Expand Down
13 changes: 13 additions & 0 deletions test/spec/ui/sections/raw_tag_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,17 @@ describe('iD.uiSectionRawTagEditor', function() {
iD.utilTriggerEvent(element.selectAll('button.remove'), 'mousedown', { button: 0 });
expect(await tags).to.eql({highway: undefined});
});

it('does not dispatch change when key is emptied', async () => {
let changeFired = false;
taglist.on('change', () => { changeFired = true; });

var keyInput = element.select('.tag-list').select('input.key');
iD.utilGetSetValue(keyInput, '');
iD.utilTriggerEvent(keyInput, 'change');

// give it a moment to ensure nothing fires
await new Promise(resolve => { window.setTimeout(resolve, 100); });
expect(changeFired).to.be.false;
});
});