Accept input and return to browse mode only on preset input fields

(closes #2957, better solution for #2380)
This commit is contained in:
Bryan Housel
2016-02-06 22:41:30 -05:00
parent b1b8d25974
commit 540700c6ef
2 changed files with 9 additions and 9 deletions
+3 -9
View File
@@ -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) {
+6
View File
@@ -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);