-
Notifications
You must be signed in to change notification settings - Fork 51
DisclosurePrimitive
- Implement a11y toggled content pattern
#2643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Disclosure Primitive
- Implement a11y toggled content patternDisclosurePrimitive
- Implement a11y toggled content pattern
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, but we should definitely test this in products before we ship. Last year we changed something similar-ish in Dropdown and it broke tests (and led us to add @preserveContentInDom
):
{{#if (or PP.isOpen @preserveContentInDom)}} |
8bb6754
to
b3c08b3
Compare
b3c08b3
to
8c332ce
Compare
Tested the changes across Similar DOM changes will have to be made for the |
Converted back to a draft pr until issues with failing tests in consumer's repos can be sorted. |
8c332ce
to
04311aa
Compare
📦 RC Packages PublishedLatest commit: f30552b |
f30552b
to
9ab9a60
Compare
📌 Summary
This PR implements usage of the
aria-controls
attribute in theDisclosurePrimitive
component to align show/hide behavior across the repo as follows in the initiative from HDS-3581.The
DisclosurePrimitive
is leveraged in theAccordion
andReveal
.🛠️ Detailed description
Currently in the
DisclosurePrimitive
, the toggled content does not follow the proper a11y structure for toggled content, or leveragearia-controls
in the preferred way.As per a11y guidance in HDS-3581, all togged content should follow a pattern leveraging
aria-controls
, and all toggled containers should not be removed from the DOM on each toggle. They should always be present, and only the content inside them is added and removed.Currently the
DisclosurePrimitive
follows a pattern where the entire content block is added and removed on each toggle, and anyaria-controls
attributes are set to theid
of this removable block. In this PR thehds-disclosure-primitive__content
block is now in the DOM at all times, and the yielded content is removed or added based on the toggle.In this PR, in the
Accordion
andReveal
, thearia-controls
attribute of the toggle elements are now set equal to acontentId
provided by theDisclosurePrimitive
. They are no longer set to theid
of content inside the yielded block.Smoke Testing
Since this PR involves updating the DOM structure of the
DisclosurePrimitive
it has been smoke tested in various products to ensure they are not relying on the existing structure in any of their tests.📸 Screenshots
Before -
Accordion
Closed

Open

After -
Accordion
Closed

Open

🔗 External links
Jira ticket: HDS-4324
👀 Component checklist
💬 Please consider using conventional comments when reviewing this PR.