Skip to content
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

Use of <details> in Accordion #2100

Closed
mimarz opened this issue Jun 4, 2024 · 1 comment · Fixed by #2363
Closed

Use of <details> in Accordion #2100

mimarz opened this issue Jun 4, 2024 · 1 comment · Fixed by #2363
Assignees
Labels
♿️ accessibility Issues related to accessibility 🕵️ investigate Needs investigation react @digdir/designsystemet-react

Comments

@mimarz
Copy link
Collaborator

mimarz commented Jun 4, 2024

Accessible Accordions has long been implemented using div, h*, and a button, as per WAI-ARIA guidelines.

One unfortunate side-effect of using the "traditional" implementation of Accordion is that display:none is often used to hide the collapsed content, which means users can't search for it using the built in browsers search (ctrl+f).

This could be remedied using hidden="until-found", but it lacks browser support.

details is often brought up as a semantic html replacement for this approach, however it lacks good screen-reader support.

Using this issue as an investigate-issue to collect information and decided on potential actions thereof.

Notes

@mimarz mimarz added react @digdir/designsystemet-react ♿️ accessibility Issues related to accessibility 🕵️ investigate Needs investigation labels Jun 4, 2024
@eirikbacker
Copy link
Contributor

Using https://u-elements.github.io/u-elements/elements/u-details solves screen reader support, is 1:1 compatible with native details/summary, and implements hidden="until-found" in all browsers that supports this. It is also compatible with, and strongly typed in all major frameworks - even React - as it is building upon the frameworks understanding of native HTML elements ☺️

eirikbacker added a commit that referenced this issue Sep 16, 2024
- Fixes #2100 🥳 
- Deprecates #2176, #2190
- Built on top of `<u-details>` for [better accessibility on
mobile](https://u-elements.github.io/u-elements/elements/u-details#accessibility)
- Removes `level` from `AccordionHeader` as this is not supported by
native `<details>`
- Removes `onHeaderClick` from `AccordionHeader` as this is identical to
adding a `onClick` handler
- JS-based animation can be removed and replaced by CSS when
`calc-size(auto)` is fully supported 🚀
- Fixes shrinking chevron on mobile/zoom
- Fixes text-align in AccordionHeader on mobile/zoom
- Follows: #2295 
- Also works in `dir="rtl"`

Question: It is now implemented so search-in-page only works when using
`defaultOpen`, as a controlled `open` should not be affected by user
interaction. Just checking - does this make sense to you guys as well?
:)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
♿️ accessibility Issues related to accessibility 🕵️ investigate Needs investigation react @digdir/designsystemet-react
Projects
Status: ✅ Done
2 participants