From 7c122f1ee053f62ccbf986b60a94bcbe0a6afd7e Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Mon, 11 Mar 2013 13:05:15 -0700 Subject: [PATCH] More keydown hacks (fixes #923) --- js/id/ui/preset_grid.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/js/id/ui/preset_grid.js b/js/id/ui/preset_grid.js index b2ed1337d..a8eb986cf 100644 --- a/js/id/ui/preset_grid.js +++ b/js/id/ui/preset_grid.js @@ -29,7 +29,7 @@ iD.ui.PresetGrid = function(context) { .attr('class', 'preset-grid-search major') .attr('placeholder','Search') .attr('type', 'search') - .one('keydown', function() { + .on('keydown', function() { // hack to let delete shortcut work when search is autofocused if (search.property('value').length === 0 && (d3.event.keyCode === d3.keybinding.keyCodes['⌫'] || @@ -37,6 +37,14 @@ iD.ui.PresetGrid = function(context) { d3.event.preventDefault(); d3.event.stopPropagation(); iD.operations.Delete([entity.id], context)(); + } else if (search.property('value').length === 0 && + (d3.event.ctrlKey || d3.event.metaKey) && + d3.event.keyCode === d3.keybinding.keyCodes['z']) { + d3.event.preventDefault(); + d3.event.stopPropagation(); + context.undo(); + } else if (!d3.event.ctrlKey && !d3.event.metaKey) { + d3.select(this).on('keydown', null); } }) .on('keyup', function() {