Drop Collapse trigger .collapsed state and rely on aria-expanded - #42771
Open
mdo wants to merge 1 commit into
Open
Drop Collapse trigger .collapsed state and rely on aria-expanded#42771mdo wants to merge 1 commit into
.collapsed state and rely on aria-expanded#42771mdo wants to merge 1 commit into
Conversation
The `.collapsed` class duplicated the state that `aria-expanded` already carries. Two signals for one thing can drift apart in custom selectors and scripts. Collapse now sets `aria-expanded` only, so `_addAriaAndCollapsedClass` becomes `_setAriaExpanded`. Update the collapse docs, the migration guide, and the cheatsheet and sidebars examples to key trigger state off `aria-expanded`. The sidebars example already styled its chevron with `.btn-toggle[aria-expanded]`, so its markup loses a class that contradicted the attribute. Co-authored-by: Julien Déramond <juderamond@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rebase of #42740 onto the current
v6-dev, where the JavaScript source has moved to TypeScript..collapsedclass on trigger elements.aria-expandedis the only state signal._addAriaAndCollapsedClassto_setAriaExpandedinjs/src/collapse.tsand dropped theCLASS_NAME_COLLAPSEDconstant..collapsedassertions fromjs/tests/unit/collapse.spec.jsand renamed the three test titles that described the class.class="collapsed"from the collapse visual test and from the cheatsheet and sidebars examples.cheatsheet.jsfrom a.collapsedclass check to anaria-expandedcheck.The sidebars example already styled its chevron with
.btn-toggle[aria-expanded="true"], so no CSS changes were needed. Its#home-collapsebutton previously carried both.collapsedandaria-expanded="true"; that contradiction is now gone.Supersedes #42740