From d9630a8820246267ae559e6e37067e56f34266c6 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Tue, 5 Mar 2013 10:10:04 -0800 Subject: [PATCH] Only do the delete hack if it's the first key press This avoids unexpectedly deleting when you spam backspace to clear a failed search query. --- index.html | 1 + js/id/ui/preset_grid.js | 2 +- js/lib/d3.one.js | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 43de200cc..ad038f359 100644 --- a/index.html +++ b/index.html @@ -27,6 +27,7 @@ + diff --git a/js/id/ui/preset_grid.js b/js/id/ui/preset_grid.js index 03d81ad67..628a094f5 100644 --- a/js/id/ui/preset_grid.js +++ b/js/id/ui/preset_grid.js @@ -26,7 +26,7 @@ iD.ui.PresetGrid = function(context) { var search = searchwrap.append('input') .attr('class', 'preset-grid-search') .attr('type', 'search') - .on('keydown', function() { + .one('keydown', function() { // hack to let delete shortcut work when search is autofocused if (search.property('value').length === 0 && (d3.event.keyCode === d3.keybinding.keyCodes['⌫'] || diff --git a/js/lib/d3.one.js b/js/lib/d3.one.js index cf4b54723..b28bd2c58 100644 --- a/js/lib/d3.one.js +++ b/js/lib/d3.one.js @@ -5,4 +5,5 @@ d3.selection.prototype.one = function (type, listener, capture) { listener.apply(this, arguments); } target.on(typeOnce, one, capture); + return this; };