File tree 7 files changed +55
-38
lines changed
7 files changed +55
-38
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 240
240
</ script >
241
241
{% endblock %}
242
242
{% block scripts %}
243
- < script src ="{{ 'assets/javascripts/bundle.2a903f2a .min.js' | url }} "> </ script >
243
+ < script src ="{{ 'assets/javascripts/bundle.029f727b .min.js' | url }} "> </ script >
244
244
{% for path in config.extra_javascript %}
245
245
< script src ="{{ path | url }} "> </ script >
246
246
{% endfor %}
Original file line number Diff line number Diff line change 13
13
{% set class = class ~ " md-nav__item--section" %}
14
14
{% endif %}
15
15
< li class ="{{ class }} md-nav__item--nested ">
16
+ {% set expanded = "navigation.expand" in features %}
17
+ {% set active = nav_item.active or expanded %}
16
18
{% set checked = "checked" if nav_item.active %}
17
- {% if "navigation.expand" in features and not checked %}
18
- < input class ="md-nav__toggle md-toggle md-toggle--indeterminate " data-md-toggle ="{{ path }} " type ="checkbox " id ="{{ path }} " checked >
19
- {% else %}
20
- < input class ="md-nav__toggle md-toggle " data-md-toggle ="{{ path }} " type ="checkbox " id ="{{ path }} " {{ checked }} >
19
+ {% if expanded and not checked %}
20
+ {% set indeterminate = "md-toggle--indeterminate" %}
21
21
{% endif %}
22
+ < input class ="md-nav__toggle md-toggle {{ indeterminate }} " data-md-toggle ="{{ path }} " type ="checkbox " id ="{{ path }} " {{ checked }} >
22
23
{% set indexes = [] %}
23
24
{% if "navigation.indexes" in features %}
24
25
{% for nav_item in nav_item.children %}
28
29
{% endfor %}
29
30
{% endif %}
30
31
{% if not indexes %}
31
- < label class ="md-nav__link " for ="{{ path }} ">
32
+ < label class ="md-nav__link " for ="{{ path }} " tabindex =" 0 " aria-expanded =" {{ nav_item.active | tojson }} " >
32
33
{{ nav_item.title }}
33
34
< span class ="md-nav__icon md-icon "> </ span >
34
35
</ label >
Original file line number Diff line number Diff line change @@ -43,6 +43,8 @@ import {
43
43
import { configuration , feature } from "./_"
44
44
import {
45
45
at ,
46
+ getActiveElement ,
47
+ getElement ,
46
48
getOptionalElement ,
47
49
requestJSON ,
48
50
setLocation ,
@@ -186,6 +188,18 @@ keyboard$
186
188
if ( typeof next !== "undefined" )
187
189
setLocation ( next )
188
190
break
191
+
192
+ /* Expand navigation, see https://bit.ly/3ZjG5io */
193
+ case "Enter" :
194
+ const active = getActiveElement ( )
195
+ if ( active instanceof HTMLLabelElement ) {
196
+ const id = `[id="${ active . htmlFor } "]`
197
+ const input = getElement < HTMLInputElement > ( id )
198
+ active . setAttribute (
199
+ "aria-expanded" ,
200
+ `${ input . checked = ! input . checked } `
201
+ )
202
+ }
189
203
}
190
204
} )
191
205
Original file line number Diff line number Diff line change 41
41
42
42
<!-- Render item with nested items -->
43
43
< li class ="{{ class }} md-nav__item--nested ">
44
+ {% set expanded = "navigation.expand" in features %}
45
+ {% set active = nav_item.active or expanded %}
44
46
45
- <!-- Active checkbox expands items contained within nested section -->
47
+ <!-- Determine checked and indeterminate state -->
46
48
{% set checked = "checked" if nav_item.active %}
47
- {% if "navigation.expand" in features and not checked %}
48
- < input
49
- class ="md-nav__toggle md-toggle md-toggle--indeterminate "
50
- data-md-toggle ="{{ path }} "
51
- type ="checkbox "
52
- id ="{{ path }} "
53
- checked
54
- />
55
- {% else %}
56
- < input
57
- class ="md-nav__toggle md-toggle "
58
- data-md-toggle ="{{ path }} "
59
- type ="checkbox "
60
- id ="{{ path }} "
61
- {{ checked }}
62
- />
49
+ {% if expanded and not checked %}
50
+ {% set indeterminate = "md-toggle--indeterminate" %}
63
51
{% endif %}
64
52
53
+ <!-- Active checkbox expands items contained within nested section -->
54
+ < input
55
+ class ="md-nav__toggle md-toggle {{ indeterminate }} "
56
+ data-md-toggle ="{{ path }} "
57
+ type ="checkbox "
58
+ id ="{{ path }} "
59
+ {{ checked }}
60
+ />
61
+
65
62
<!-- Determine all nested items that are index pages -->
66
63
{% set indexes = [] %}
67
64
{% if "navigation.indexes" in features %}
74
71
75
72
<!-- Render toggle to expand nested items -->
76
73
{% if not indexes %}
77
- < label class ="md-nav__link " for ="{{ path }} ">
74
+ < label
75
+ class ="md-nav__link "
76
+ for ="{{ path }} "
77
+ tabindex ="0 "
78
+ aria-expanded ="{{ nav_item.active | tojson }} "
79
+ >
78
80
{{ nav_item.title }}
79
81
< span class ="md-nav__icon md-icon "> </ span >
80
82
</ label >
You can’t perform that action at this time.
0 commit comments