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.
This commit is contained in:
John Firebaugh
2013-03-05 10:10:04 -08:00
parent 3a680b027f
commit d9630a8820
3 changed files with 3 additions and 1 deletions
+1
View File
@@ -27,6 +27,7 @@
<script src='js/lib/d3.trigger.js'></script>
<script src='js/lib/d3.keybinding.js'></script>
<script src='js/lib/d3.clip.js'></script>
<script src='js/lib/d3.one.js'></script>
<script src='js/lib/d3-compat.js'></script>
<script src='js/lib/bootstrap-tooltip.js'></script>
<script src='js/lib/rtree.js'></script>
+1 -1
View File
@@ -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['⌫'] ||
+1
View File
@@ -5,4 +5,5 @@ d3.selection.prototype.one = function (type, listener, capture) {
listener.apply(this, arguments);
}
target.on(typeOnce, one, capture);
return this;
};