Repository navigation
refactor!: re-implement details and accordion structure - #5093
Conversation
3dd67aa to
7fda924
Compare
| * The WAI ARIA Best Practices also recommend setting `aria-level` depending | ||
| * on what level the headings are. It is hard to determine the level of a heading | ||
| * algorithmically, and setting it is not strictly required to have an accessible | ||
| * accordion. To keep things easier to use, this element does not set `aria-level` |
There was a problem hiding this comment.
Are you planning to add an API for it on the flow side?
There was a problem hiding this comment.
Yes, that's the idea. For each AccordionPanel, we would create an instance of AccordionHeading on the server side and then expose it e.g. getHeadingComponent() API, to enable setting aria-level e.g. like this:
Accordion accordion = new Accordion();
AccordionPanel panel = accordion.add("Heading text", new Div());
panel.getHeadingComponent().getElement().setAttribute("aria-level", "3");Does that sound reasonable? Or do you have any other suggestions on how the API might look like?
There was a problem hiding this comment.
Thanks for already considering it! This would reduce the boilerplate I've created in my apps where I've manually added h* elements inside the header.
I'm totally fine with the API, but I'm wondering if people would find / use them. Would it make sense to have something like an AriaLevel enum with 1-6 allowing to create constructors like:
new Details(String caption, Component content)
new Details(String caption, AriaLevel headingLevel, Component content)
new Details(String caption, AriaLevel headingLevel, Component content)
// AriaLevel could be optional / nullable allowing it to be not set if not present like in the first constructor
There was a problem hiding this comment.
We could consider it for Accordion. As for Details, I'm inclined to follow the suggestion from #90:
There are three possibilities for resolving this. The first is to remove role="heading" from the component. While it is valid for a heading to be used in this way, it is more common in an Accordion pattern. Details patterns, such as the W3C WAI-ARIA Authoring Practices 1.1 Disclosure (Show/Hide), do not wrap the button control in a heading.
There was a problem hiding this comment.
Totally valid! Just checked my application and I have only accordions in use as of now, so I'm totally fine with your idea 👍
7fda924 to
ca5caf5
Compare
|
Kudos, SonarCloud Quality Gate passed!
|
|
This ticket/PR has been released with Vaadin 24.0.0.alpha6 and is also targeting the upcoming stable 24.0.0 version. |








Description
This is a first part of re-implementing the
vaadin-detailsandvaadin-accordioncomponents for V24.Some things are still marked as TODOs, especially logic for setting
aria-controls+aria-labelledby.I'm going to address those in a separate PR because this one is already way too big.
Part of #5077
Fixes #412
Fixes #90
Overview
This PR contains several breaking changes that aim to improve accessibility for two components.
<vaadin-details>vaadin-details-summarywhich hasrole="button"and usesButtonMixininternally,role="heading"from Shadow DOM ofvaadin-detailsas not needed,summaryproperty that can be used aslabelproperty invaadin-checkboxetc.<vaadin-accordion>vaadin-accordion-panelfromvaadin-detailsso that styles won't apply to both,vaadin-accordion-headingelement withrole="heading"in thesummaryslot,<button>in Shadow DOM withdelegatesFocus: true.Type of change
Note
Decided to keep
summaryslot in case ofvaadin-accordion-panelin order to ensure that on the Flow side, theAccordionPanelcan still have the backwards compatible API, and maybe even extendDetailsif needed.