Skip to content

Commit

Permalink
Accept input and return to browse mode only on preset input fields
Browse files Browse the repository at this point in the history
(closes #2957, better solution for #2380)
  • Loading branch information
bhousel committed Feb 7, 2016
1 parent b1b8d25 commit 540700c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 3 additions & 9 deletions js/id/modes/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand All @@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions js/id/ui/preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 540700c

Please sign in to comment.