From 5d70ba79d3ff79a3f13cdaa55968884de7fb7fed Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Tue, 19 Feb 2013 17:49:01 +0100 Subject: [PATCH 1/2] Taglist: do not addTag when presssing TAB in shiftKey mode --- js/id/ui/taglist.js | 3 ++- test/spec/ui/inspector.js | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/js/id/ui/taglist.js b/js/id/ui/taglist.js index 15041d1db..bcc6413d8 100644 --- a/js/id/ui/taglist.js +++ b/js/id/ui/taglist.js @@ -182,7 +182,8 @@ iD.ui.Taglist = function() { function pushMore() { if (d3.event.keyCode === 9 && - list.selectAll('li:last-child input.value').node() === this) { + list.selectAll('li:last-child input.value').node() === this && + !d3.event.shiftKey) { addTag(); focusNewKey(); d3.event.preventDefault(); diff --git a/test/spec/ui/inspector.js b/test/spec/ui/inspector.js index 99fb7d5c5..f572d77e0 100644 --- a/test/spec/ui/inspector.js +++ b/test/spec/ui/inspector.js @@ -75,4 +75,21 @@ describe("iD.ui.Inspector", function () { expect(spy).to.have.been.calledWith(entity, tags); }); + + it("adds tags when pressing the TAB key on last input.value", function () { + expect(element.selectAll('.tag-list li')[0].length).to.eql(1); + var input = d3.select('.tag-list li:last-child input.value')[0][0]; + happen.keydown(d3.select(input).node(), {keyCode: 9}); + expect(element.selectAll('.tag-list li')[0].length).to.eql(2); + expect(element.select('.tag-list').selectAll("input")[0][2].value).to.be.empty; + expect(element.select('.tag-list').selectAll("input")[0][3].value).to.be.empty; + }); + + it("does not add a tag when pressing TAB while shift is pressed", function () { + expect(element.selectAll('.tag-list li')[0].length).to.eql(1); + var input = d3.select('.tag-list li:last-child input.value')[0][0]; + happen.keydown(d3.select(input).node(), {keyCode: 9, shiftKey: true}); + expect(element.selectAll('.tag-list li')[0].length).to.eql(1); + }); + }); From 2b4cfe87d078ddd8ae3c0e0ff7598e39a355516f Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Tue, 19 Feb 2013 13:14:12 -0500 Subject: [PATCH 2/2] Fix async combobox --- js/lib/d3.combobox.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/js/lib/d3.combobox.js b/js/lib/d3.combobox.js index 63f741107..8a2e94d40 100644 --- a/js/lib/d3.combobox.js +++ b/js/lib/d3.combobox.js @@ -137,7 +137,7 @@ d3.combobox = function() { var prevValue, prevCompletion; - function autocomplete() { + function autocomplete(e, data) { var value = input.property('value'), match; @@ -150,7 +150,7 @@ d3.combobox = function() { } // backspace - if (d3.event.keyCode === 8) { + if (e.keyCode === 8) { prevValue = value; prevCompletion = ''; @@ -183,12 +183,14 @@ d3.combobox = function() { value = input.property('value'); } + var e = d3.event; + function render(data) { if (data.length) show(); else hide(); - autocomplete(); + autocomplete(e, data); updateSize();