fix: make nav controller more universal
This commit is contained in:
+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