File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -71,7 +71,23 @@ function CatchEscape(e) {
7171 if ( ! ( e . target . parentNode . parentNode instanceof HTMLUListElement ) ) {
7272 return ;
7373 }
74- ToggleMenu ( e . target . parentNode . parentNode ) ;
74+
75+ Initialize ( e . target . parentNode . parentNode ) ;
76+ }
77+
78+ // The initalize function will take a container and set all of the lists inside
79+ // to the initial state (collapsed).
80+ function Initialize ( container ) {
81+ let menus = container . getElementsByTagName ( 'ul' ) ;
82+ $ ( menus ) . each ( function ( index , menu ) {
83+ menu . setAttribute ( "hidden" , "" ) ;
84+ menu . previousElementSibling . setAttribute ( "aria-expanded" , "false" ) ;
85+ } ) ;
86+ // As long as we aren't at the top level, close the current container too.
87+ if ( ! ( container . classList . contains ( "navigation" ) ) ) {
88+ container . setAttribute ( "hidden" , "" ) ;
89+ container . previousElementSibling . setAttribute ( "aria-expanded" , "false" ) ;
90+ }
7591}
7692
7793// The ToggleMenu function is how the navigation functions. It hides or shows
You can’t perform that action at this time.
0 commit comments