fix: make nav controller more universal
This commit is contained in:
1 parent
c1d7898f77
commit
538bec0e83
1 file changed
+10
-6
+10
-6
@@ -21,12 +21,16 @@ export default class extends Controller {
|
||||
}
|
||||
|
||||
expandedValueChanged(expanded) {
|
||||
this.buttonTarget.setAttribute('aria-expanded', expanded)
|
||||
this.subnavTarget.setAttribute('aria-hidden', !expanded)
|
||||
if (true === expanded) {
|
||||
this.subnavTarget.classList.remove(...this.hiddenClasses)
|
||||
} else {
|
||||
this.subnavTarget.classList.add(...this.hiddenClasses)
|
||||
if (this.hasButtonTarget) {
|
||||
this.buttonTarget.setAttribute('aria-expanded', expanded)
|
||||
}
|
||||
if (this.hasSubnavTarget) {
|
||||
this.subnavTarget.setAttribute('aria-hidden', !expanded)
|
||||
if (true === expanded) {
|
||||
this.subnavTarget.classList.remove(...this.hiddenClasses)
|
||||
} else {
|
||||
this.subnavTarget.classList.add(...this.hiddenClasses)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user