From 7c20bd37225bc5a06aa8ec3c4f6b183d99264ddc Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Tue, 28 May 2013 13:07:27 -0700 Subject: [PATCH] Ensure combobox suggestion menu is closed on blur The combobox's blur handler needs to be called prior to the tag editor's blur handler. The latter can cause a re-render, which will rebind handlers. Rebound handlers are not called during the same event dispatch cycle, so when the combobox blur handler is last, it sometimes doesn't get called, stranding the menu. --- js/id/ui/raw_tag_editor.js | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/js/id/ui/raw_tag_editor.js b/js/id/ui/raw_tag_editor.js index 4feaf5c1e..9b854d338 100644 --- a/js/id/ui/raw_tag_editor.js +++ b/js/id/ui/raw_tag_editor.js @@ -86,24 +86,6 @@ iD.ui.RawTagEditor = function(context) { $items.order(); - $items.select('input.key') - .property('value', function(d) { - return d.key; - }) - .on('blur', keyChange) - .on('change', keyChange); - - $items.select('input.value') - .property('value', function(d) { - return d.value; - }) - .on('blur', valueChange) - .on('change', valueChange) - .on('keydown.push-more', pushMore); - - $items.select('button.remove') - .on('click', removeTag); - $items.each(function(tag) { d3.select(this) .each(bindTypeahead) @@ -111,6 +93,20 @@ iD.ui.RawTagEditor = function(context) { .call(tag.reference.body); }); + $items.select('input.key') + .property('value', function(d) { return d.key; }) + .on('blur', keyChange) + .on('change', keyChange); + + $items.select('input.value') + .property('value', function(d) { return d.value; }) + .on('blur', valueChange) + .on('change', valueChange) + .on('keydown.push-more', pushMore); + + $items.select('button.remove') + .on('click', removeTag); + $items.exit() .remove();