Prevent more accidental shortcut triggers
Do not allow browser keyboard shortcuts to trigger route functions, e.g. pressing Ctrl+P triggers printing in most browsers, but should not at the same time switch BRouter-Web to POI mode. This can be prevented by filtering for modifiers. In the same fashion, when modal dialogs or dropdowns are open it should not be possible to activate map functions in the background now. Finally, inhibit shortcuts in number input fields too, as found in the editable number input fields in the customize profile options. Previously only regular text input fields were protected. To make those checks easier to use, they are deduplicated and moved to Util.js.
This commit is contained in:
parent
fbd3d3d383
commit
08c8cfa8be
4 changed files with 38 additions and 20 deletions
|
|
@ -61,13 +61,12 @@ BR.PoiMarkers = L.Control.extend({
|
|||
},
|
||||
|
||||
_keydownListener: function(e) {
|
||||
// Suppress shortcut handling when a text input field is focussed
|
||||
if (document.activeElement.type == 'text' || document.activeElement.type == 'textarea') {
|
||||
if (!BR.Util.keyboardShortcutsAllowed(e)) {
|
||||
return;
|
||||
}
|
||||
if (e.keyCode === this.options.shortcut.draw.disable && !e.repeat) {
|
||||
if (e.keyCode === this.options.shortcut.draw.disable) {
|
||||
this.draw(false);
|
||||
} else if (e.keyCode === this.options.shortcut.draw.enable && !e.repeat) {
|
||||
} else if (e.keyCode === this.options.shortcut.draw.enable) {
|
||||
this.draw(true);
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue