File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change 56
56
* Toggles active class on the primary nav panel
57
57
* 1) Select all nav triggers and cycle through them
58
58
* 2) On click, find the nav panel within the header
59
- * 3) If the navPanel already has active class, remove it on click.
60
- * 4) If the navPanel does not have an active class, add it on click.
59
+ * 3) If the navPanel already has active class, remove it on click, as well as the aria-expanded attributes value .
60
+ * 4) If the navPanel does not have an active class, add it on click, as well as the aria-expanded attributes value .
61
61
*/
62
62
var navToggle = document . querySelectorAll ( '.js-nav-trigger' ) ; /* 1 */
63
63
67
67
navToggle [ i ] . addEventListener ( 'click' , function ( event ) {
68
68
/* 2 */
69
69
event . preventDefault ( ) ;
70
- var navToggleParent = this . parentNode ; /* 2 */
70
+ var navToggleElement = this ;
71
+ var navToggleParent = navToggleElement . parentNode ; /* 2 */
71
72
var navPanel = navToggleParent . querySelector ( '.js-nav-panel' ) ; /* 2 */
72
73
73
74
if ( navPanel . classList . contains ( 'is-active' ) ) {
74
75
/* 3 */
75
76
navPanel . classList . remove ( 'is-active' ) ;
77
+ navToggleElement . setAttribute ( 'aria-expanded' , 'false' ) ;
76
78
} else {
77
79
/* 4 */
78
80
navPanel . classList . add ( 'is-active' ) ;
81
+ navToggleElement . setAttribute ( 'aria-expanded' , 'true' ) ;
79
82
}
80
83
} ) ;
81
84
}
Original file line number Diff line number Diff line change 47
47
.c-header__nav-btn {
48
48
margin-left : auto ;
49
49
50
+ // Pseudo / breakout element that enables clicking/tabbing outside of the menu to close it
51
+ & [aria-expanded = " true" ]::after {
52
+ position : fixed ;
53
+ top : 0 ;
54
+ left : 0 ;
55
+
56
+ content : " " ;
57
+
58
+ width : 100vw ;
59
+ height : 100vh ;
60
+ }
61
+
50
62
@media all and (min-width : $bp-large ) {
51
63
display : none ;
52
64
}
You can’t perform that action at this time.
0 commit comments