@@ -42,6 +42,15 @@ export class HotKeysElement extends LitElement {
42
42
this . searchHotKeyEnabled = this . config . addons . hotkeys . search . enabled ;
43
43
}
44
44
45
+ isInput ( element ) {
46
+ return (
47
+ element . tagName === "INPUT" ||
48
+ element . tagName === "TEXTAREA" ||
49
+ element . tagName === "READTHEDOCS-SEARCH" ||
50
+ element . contentEditable === "true"
51
+ ) ;
52
+ }
53
+
45
54
_handleKeydown = ( e ) => {
46
55
// Close docdiff with single-stroke `d` (no Ctrl, no Shift, no Alt and no Meta)
47
56
// (I'm checking `document.activeElement` to check if it not inside an INPUT to avoid enable/disable while typing on forms)
@@ -54,9 +63,7 @@ export class HotKeysElement extends LitElement {
54
63
this . docDiffHotKeyEnabled &&
55
64
keyboardEventToString ( e ) ===
56
65
this . config . addons . hotkeys . doc_diff . trigger &&
57
- document . activeElement . tagName !== "INPUT" &&
58
- document . activeElement . tagName !== "TEXTAREA" &&
59
- document . activeElement . tagName !== "READTHEDOCS-SEARCH"
66
+ ! this . isInput ( document . activeElement )
60
67
) {
61
68
if ( this . docDiffEnabled ) {
62
69
event = new CustomEvent ( EVENT_READTHEDOCS_DOCDIFF_HIDE ) ;
@@ -69,9 +76,7 @@ export class HotKeysElement extends LitElement {
69
76
if (
70
77
this . searchHotKeyEnabled &&
71
78
keyboardEventToString ( e ) === this . config . addons . hotkeys . search . trigger &&
72
- document . activeElement . tagName !== "INPUT" &&
73
- document . activeElement . tagName !== "TEXTAREA" &&
74
- document . activeElement . tagName !== "READTHEDOCS-SEARCH"
79
+ ! this . isInput ( document . activeElement )
75
80
) {
76
81
event = new CustomEvent ( EVENT_READTHEDOCS_SEARCH_SHOW ) ;
77
82
}
0 commit comments