File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
packages/web/src/components Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ export class GcdsSideNav {
8585
8686 @Listen ( 'focusout' , { target : 'document' } )
8787 async focusOutListener ( e ) {
88- if ( ! this . el . contains ( e . relatedTarget ) ) {
88+ if ( e . relatedTarget !== null && e . relatedTarget !== this . el && ! this . el . contains ( e . relatedTarget ) ) {
8989 if ( this . navSize == 'mobile' ) {
9090 if ( this . mobile . hasAttribute ( 'open' ) ) {
9191 await this . mobile . toggleNav ( ) ;
@@ -98,6 +98,9 @@ export class GcdsSideNav {
9898 async keyDownListener ( e ) {
9999 if ( this . el . contains ( document . activeElement ) ) {
100100 handleKeyDownNav ( e , this . el , this . navItems ) ;
101+ } if ( this . navSize == 'mobile' && this . mobile . open == true && e . key == 'Escape' ) {
102+ // Close mobile nav on ESC
103+ await this . mobile . toggleNav ( ) ;
101104 }
102105 }
103106
Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ export class GcdsTopNav {
102102
103103 @Listen ( 'focusout' , { target : 'document' } )
104104 async focusOutListener ( e ) {
105- if ( ! this . el . contains ( e . relatedTarget ) ) {
105+ if ( e . relatedTarget !== null && e . relatedTarget !== this . el && ! this . el . contains ( e . relatedTarget ) ) {
106106 if ( this . navSize == 'mobile' ) {
107107 if ( this . mobile . hasAttribute ( 'open' ) ) {
108108 await this . mobile . toggleNav ( ) ;
@@ -115,6 +115,9 @@ export class GcdsTopNav {
115115 async keyDownListener ( e ) {
116116 if ( this . el . contains ( document . activeElement ) ) {
117117 handleKeyDownNav ( e , this . el , this . navItems ) ;
118+ } else if ( this . navSize == 'mobile' && this . mobile . open == true && e . key == 'Escape' ) {
119+ // Close mobile nav on ESC
120+ await this . mobile . toggleNav ( ) ;
118121 }
119122 }
120123
You can’t perform that action at this time.
0 commit comments