File tree Expand file tree Collapse file tree 7 files changed +17
-24
lines changed
workspaces/documentation-ui Expand file tree Collapse file tree 7 files changed +17
-24
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,10 @@ export class Locker {
1111 this . renderUnlock ( ) ;
1212
1313 document . addEventListener ( "keydown" , ( event ) => {
14- if ( window . disableShortcuts ) {
14+ const isNetworkViewHidden = this . networkView . classList . contains ( "hidden" ) ;
15+ const isTargetInput = event . target . tagName === "INPUT" ;
16+ const isTargetPopup = event . target . id === "popup--background" ;
17+ if ( isNetworkViewHidden || isTargetInput || isTargetPopup ) {
1518 return ;
1619 }
1720
Original file line number Diff line number Diff line change @@ -29,11 +29,10 @@ export class ViewNavigation {
2929 }
3030
3131 document . addEventListener ( "keydown" , ( event ) => {
32- if ( window . disableShortcuts ) {
33- return ;
34- }
35-
36- if ( window . searchbar . background . classList . contains ( "show" ) ) {
32+ const isWikiOpen = document . getElementById ( "documentation-root-element" ) . classList . contains ( "slide-in" ) ;
33+ const isTargetPopup = event . target . id === "popup--background" ;
34+ const isTargetInput = event . target . tagName === "INPUT" ;
35+ if ( isTargetPopup || isWikiOpen || isTargetInput ) {
3736 return ;
3837 }
3938
Original file line number Diff line number Diff line change @@ -25,8 +25,6 @@ export class Popup {
2525 return ;
2626 }
2727
28- window . disableShortcuts = true ;
29-
3028 this . templateName = template . name ;
3129 this . dom . popup . appendChild ( template . HTMLElement ) ;
3230 // TODO: apply additional css customization
@@ -61,7 +59,6 @@ export class Popup {
6159 return ;
6260 }
6361
64- window . disableShortcuts = false ;
6562 this . dom . popup . innerHTML = "" ;
6663 this . templateName = null ;
6764 this . #cleanupClickOutside( ) ;
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ const kDefaultHotKeys = {
1414 wiki : "W" ,
1515 lock : "L"
1616} ;
17+ const kShortcutInputTargetIds = new Set ( Object . keys ( kDefaultHotKeys ) ) ;
1718
1819export class Settings {
1920 static defaultMenuName = "info" ;
@@ -52,7 +53,7 @@ export class Settings {
5253 input . value = "" ;
5354
5455 const onKeyDown = ( event ) => {
55- if ( window . disableShortcuts ) {
56+ if ( kShortcutInputTargetIds . has ( event . target . id ) === false ) {
5657 return ;
5758 }
5859
Original file line number Diff line number Diff line change @@ -31,7 +31,9 @@ export class Wiki {
3131 } ) ;
3232
3333 document . addEventListener ( "keydown" , ( event ) => {
34- if ( window . disableShortcuts ) {
34+ const isTargetInput = event . target . tagName === "INPUT" ;
35+ const isTargetPopup = event . target . id === "popup--background" ;
36+ if ( isTargetInput || isTargetPopup ) {
3537 return ;
3638 }
3739
Original file line number Diff line number Diff line change @@ -112,14 +112,11 @@ export class NetworkNavigation {
112112 this . #dependenciesMapByLevel. set ( 0 , this . rootNodeParams ) ;
113113
114114 document . addEventListener ( "keydown" , ( event ) => {
115- if ( window . disableShortcuts ) {
116- return ;
117- }
118-
119115 const isNetworkViewHidden = document . getElementById ( "network--view" ) . classList . contains ( "hidden" ) ;
120116 const isWikiOpen = document . getElementById ( "documentation-root-element" ) . classList . contains ( "slide-in" ) ;
121- const isSearchOpen = window . searchbar . background . classList . contains ( "show" ) ;
122- if ( isNetworkViewHidden || isWikiOpen || isSearchOpen ) {
117+ const isTargetPopup = event . target . id === "popup--background" ;
118+ const isTargetInput = event . target . tagName === "INPUT" ;
119+ if ( isNetworkViewHidden || isWikiOpen || isTargetPopup || isTargetInput ) {
123120 return ;
124121 }
125122
Original file line number Diff line number Diff line change @@ -92,14 +92,8 @@ export function render(rootElement, options = {}) {
9292 rootElement . appendChild ( mainContainer ) ;
9393
9494 document . addEventListener ( "keydown" , ( event ) => {
95- if ( window . disableShortcuts ) {
96- return ;
97- }
98-
9995 const isWikiOpen = document . getElementById ( "documentation-root-element" ) . classList . contains ( "slide-in" ) ;
100- // should not be possible but just in case
101- const isSearchOpen = window . searchbar . background . classList . contains ( "show" ) ;
102- if ( ! isWikiOpen || isSearchOpen ) {
96+ if ( ! isWikiOpen ) {
10397 return ;
10498 }
10599
You can’t perform that action at this time.
0 commit comments