diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-09-26 18:14:00 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-26 18:14:00 -0400 |
commit | c364714c8188ab1503b53b096a70b1fd5b6b3055 (patch) | |
tree | 5f3a2af8b3ec19dbe3dfc88514f2b87e1a4bfc60 /ext/js/dom | |
parent | d739ccd63f0554f0f880e7463355dd5c4ff166e4 (diff) |
Fix hotkey input field conflict (#1963)
* Move comment
* Add DocumentUtil.isInputElement
* Use DocumentUtil.isInputElement
* Fix simple hotkeys (shift or no modifier) preventing text field input
* Improve input detection
* Validate key is an input character before blocking hotkey
* Simplify
* Fix incorrect property
Diffstat (limited to 'ext/js/dom')
-rw-r--r-- | ext/js/dom/document-util.js | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/ext/js/dom/document-util.js b/ext/js/dom/document-util.js index da4d3e61..0338d452 100644 --- a/ext/js/dom/document-util.js +++ b/ext/js/dom/document-util.js @@ -311,6 +311,22 @@ class DocumentUtil { return !(browser === 'firefox' || browser === 'firefox-mobile') || os === 'mac'; } + static isInputElementFocused() { + const element = document.activeElement; + if (element === null) { return false; } + const type = element.nodeName.toUpperCase(); + switch (type) { + case 'INPUT': + case 'TEXTAREA': + case 'SELECT': + return true; + default: + return element.isContentEditable; + } + } + + // Private + static _getActiveButtons(event, array) { let {buttons} = event; if (typeof buttons === 'number' && buttons > 0) { @@ -325,8 +341,6 @@ class DocumentUtil { } } - // Private - _setImposterStyle(style, propertyName, value) { style.setProperty(propertyName, value, 'important'); } |