-
Notifications
You must be signed in to change notification settings - Fork 153
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
Collapse: fix a11y violation (interactive nested elements) #4553
Conversation
Storybook staging is available at https://kiwicom-orbit-sarka-a11y-collapse.surge.sh |
Size Change: +39 B (+0.01%) Total Size: 459 kB
ℹ️ View Unchanged
|
Deploying orbit with Cloudflare Pages
|
8f0502d
to
60e7a82
Compare
2879382
to
2e0e87e
Compare
</div> | ||
<Stack inline grow={false} align="center" spacing="none"> | ||
{actions && ( | ||
<div aria-labelledby={labelID} className="mx-300 flex items-center"> |
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.
The div is visible only when actions !== null
(because of the set x-margin). I also set the aria-labelledby
attribute to inform the user about the connection between the action button/link and the current collapse element. I removed the "eslint ignoring comment" as we don't need the onClick
function on the div.
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.
The div is visible only when actions !== null (because of the set x-margin).
Makes sense! although I'm not sure I understand the "set x-margin" part.
I also set the aria-labelledby attribute to inform the user about the connection between the action button/link and the current collapse element.
I'm not sure if this is correct 🤔. The div with labelID
only collapses/expands the content whereas actions
might trigger a completely different functionality (e.g. clear some collapsed filters).
@DSil I'm interested in your opinion here.
I removed the "eslint ignoring comment" as we don't need the onClick function on the div.
Perfect! The fewer suppressed warnings, the better.
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.
I checked with @DSil offline, and we don't need the aria-labelledby on the actions wrapper
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.
Regarding using labelled-by
in static div: I think you're correct and we probably should get rid of it. I think
additional info/text about the link (action component) should be set to this component itself? 🤔 but I'm not 100% sure.
NOTE 💡 : Yesterday I've received a newsletter with a link leading to this article about using aria-label
, aria-labelledby
.
2e0e87e
to
2d95bc1
Compare
test("First Collapse opens on label click and last Collapse opens on arrow button click", async ({ | ||
mount, | ||
}) => { | ||
const component = await mount(<CollapseStory />); |
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.
I included visual tests of collapsed component on click for wrapper & arrow button within one test, because I wanted to avoid the huge number of screenshots.
7203d3c
to
135ffa8
Compare
bb0a0f2
to
c8e076c
Compare
5578a1f
to
cb02521
Compare
packages/orbit-components/src/Collapse/__tests__/index.test.tsx
Outdated
Show resolved
Hide resolved
cb02521
to
0264f8f
Compare
); | ||
|
||
const toggleButton = | ||
triggerButton === "label" |
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.
I kept it.each
loop and added a condition to distinguish between "label" button and "arrow" button. It was tough to find a way how to distinguish these two elements and avoid flakiness, in the end I used expanded: false
option which is available only for arrow button. The label button is targeted byText
.
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.
I knew it was challenging 😏 but well done!!
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.
Greeeeat 🎉
This Pull Request meets the following criteria:
For new components:
d.ts
files and are exported inindex.d.ts
Closes https://kiwicom.atlassian.net/browse/FEPLT-2186
✨
Description by Callstackai
This PR fixes an accessibility violation by addressing interactive nested elements in the Collapse component.
Diagrams of code changes
Files Changed
Closes https://kiwicom.atlassian.net/browse/FEPLT-2186