-
Notifications
You must be signed in to change notification settings - Fork 218
fix(accordion): correct trigger semantics and guard keyboard events i… #838
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
base: main
Are you sure you want to change the base?
Conversation
cef7db6
to
fa2bd23
Compare
…n editable fields - Remove incorrect heading semantics from trigger - Use proper button semantics with aria-expanded/aria-controls - Validate ARIA structure: trigger must be a button and be wrapped by a semantic heading - Add robust keyboard guarding: ignore navigation/toggle handling inside inputs,etc. - Allow modifier combos (Ctrl/Meta/Alt) to pass through keyboard handling - Prevent default only for relevant keys when the accordion has focus and based on orientation - textareas accept newlines without toggling - Expands e2e test coversage: - Add ARIA semantics checks (trigger/button, heading wrapper, region with aria-labelledby) - Cover single/multiple behavior, horizontal/vertical navigation, Home/End, focus wrapping - Verify form input interactions (input/textarea/select/contenteditable) don’t toggle accordion - Add inert behavior checks for focusables in closed panels - Run axe checks for default stories Fixes: #792,#833
fa2bd23
to
3ffa551
Compare
@ashley-hunter @marcjulian curious to hear your thoughts on this. Should I write a migration for this? Feel like it should be doable and would definitely avoid users having to deal with breaking apps? |
Hey @goetzrobin, short feedback on this. I'm not sure if we should but a button into a heading. Headings can only contain phrasing content, and a is interactive content that makes the HTML invalid and harms accessibility. |
Hey @MerlinMoos! I actually had the same gut reaction, but this is from the waria specs: Each accordion header button is wrapped in an element with role heading that has a value set for aria-level that is appropriate for the information architecture of the page. Here is the full article for reference: https://www.w3.org/WAI/ARIA/apg/patterns/accordion/ But I guess we could make the role an input so people could turn it off? |
Im fine by that and you are right. Sorry I was not thinking about it... Till the button is the only element its valid and recommended :) we can keep as it is, sorry. |
Thanks @goetzrobin! Looks good! I think we should be able to write a healthcheck to automate this - would be great if possible 😊 |
@goetzrobin since you are updating accordion here, another quick win I saw we have a few @hostlisteners in brn-accordion.ts, maybe we can move them to host property as well? Although now that I think about it, maybe there was a reason we didn't, vaguely recall maybe @elite-benni saying something about this but maybe I'm imagining things. Also nice job on the keyboard guarding, I was just thinking if our select was inside the accordion if this would work with keyboard nav and I believe the role checks will cover that! |
…n editable fields
Fixes: #792,#833
PR Checklist
Please check if your PR fulfills the following requirements:
guidelines: https://github.com/spartan-ng/spartan/blob/main/CONTRIBUTING.md#-commit-message-guidelines
PR Type
What kind of change does this PR introduce?
Which package are you modifying?
Primitives
Others
What is the current behavior?
See commit message above
Closes #792,#833
What is the new behavior?
Does this PR introduce a breaking change?
We remove the hard coded h3 in favor of prompting the user to wrap the trigger with an h[ANYLEVEL] element themselves. Updates the docs to reflect that
Other information