-
Notifications
You must be signed in to change notification settings - Fork 44
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
DisclosurePrimitive
- Implement a11y toggled content pattern
#2643
base: main
Are you sure you want to change the base?
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 |
</div> | ||
{{#if this.isOpen}} | ||
<div class="hds-disclosure-primitive__content"> | ||
<div class="hds-disclosure-primitive__content" id={{this._contentId}}> |
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 could a breaking change if consumers use hds-disclosure-primitive__content
selector to check if disclosed content is visible or not. If we find through testing that it does not affect tests then we're good. Otherwise we'd either have to find another way or defer this feature to a major release.
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.
Yeah I agree it could be seen as breaking. I tested it out in atlas locally and ran it through tests in cloud-ui and nothing seems to be breaking, but not sure about other consumers.
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.
Smoke testing sounds good. Searching for this class being used as a selector I could only find a few instances in one test in nomad. I would try and check that test suite and if it's all good we can consider releasing this as a patch.
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.
Tests seem to pass for me. If anything it may make the test they have never fail. They are testing that hds-disclosure-primitive__content
is present on the page, and with the new approach it will always be present and only the inner content will be added / removed.
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.
Great! Thanks for checking! On that basis we can class it as a patch indeed.
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.
Went back through this after I realized my changes from the testing branch weren't updating the dist for local testing in Nomad. There does seem to be a test failure now on that test you highlighted. The test is related to a component they have that uses a reveal inside of a dropdown. So we may have to hold off on this change...
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.
We can hold this PR for now and work it from another angle. Maybe we can update their tests to not need this class, then get this change in. Otherwise, as you mentioned in the sister PR, we can roll it out in a major.
Converted back to a draft pr until issues with failing tests in consumer's repos can be sorted. |
📌 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.📸 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.