From 540700c6ef3561595e08a5efb913175bec51bc40 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Sat, 6 Feb 2016 22:41:30 -0500 Subject: [PATCH] Accept input and return to browse mode only on preset input fields (closes #2957, better solution for #2380) --- js/id/modes/select.js | 12 +++--------- js/id/ui/preset.js | 6 ++++++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/js/id/modes/select.js b/js/id/modes/select.js index 985ccd22c..44e3d8394 100644 --- a/js/id/modes/select.js +++ b/js/id/modes/select.js @@ -146,14 +146,9 @@ iD.modes.Select = function(context, selectedIDs) { } } - function ret() { + function esc() { if (!context.inIntro()) { - // only accept changes if focused on a non-search input field.. #2912, #2380 - var el = document.activeElement, - tagName = el && el.tagName.toLowerCase(); - if (tagName === 'input' && el.type !== 'search') { - context.enter(iD.modes.Browse(context)); - } + context.enter(iD.modes.Browse(context)); } } @@ -169,8 +164,7 @@ iD.modes.Select = function(context, selectedIDs) { operations.unshift(iD.operations.Delete(selectedIDs, context)); keybinding - .on('⎋', ret, true) - .on('↩', ret, true) + .on('⎋', esc, true) .on('space', toggleMenu); operations.forEach(function(operation) { diff --git a/js/id/ui/preset.js b/js/id/ui/preset.js index 5b1978617..60555e938 100644 --- a/js/id/ui/preset.js +++ b/js/id/ui/preset.js @@ -157,6 +157,12 @@ iD.ui.preset = function(context) { d3.select(this) .call(field.input) + .selectAll('input') + .on('keydown', function() { + if (d3.event.keyCode === 13) { // enter + context.enter(iD.modes.Browse(context)); + } + }) .call(reference.body) .select('.form-label-button-wrap') .call(reference.button);