-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(aria/disclosure): add disclosure pattern #32704
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?
feat(aria/disclosure): add disclosure pattern #32704
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Implements the WAI-ARIA Disclosure pattern with two directives. DisclosureTrigger (ngDisclosureTrigger) is a toggle button that controls content visibility with keyboard support (Enter, Space) and ARIA attributes (aria-expanded, aria-controls). DisclosureContent (ngDisclosureContent) is a content panel that shows/hides based on trigger state.
7dc2925 to
b44abf2
Compare
crisbeto
left a comment
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.
Will leave it up for discussion, but I'm not sure we need directives for this pattern specifically, considering that it's basically an @if statement.
|
Thanks for the contribution! There is |
|
Thank you for the replies and for explaining the topic. I learned a lot while working on this feature, so the time was definitely not wasted 😄 If i could ask for little code check, what do you think about grouping tests based on POUR principles? Does it make sense to you?
|
Disclosure Pattern
Updated .ng-dev/commit-message.mts with aria/disclosure scope.
Yes, both are tested
private pattern - src/aria/private/disclosure/disclosure.spec.ts
public directives - src/aria/disclosure/disclosure.spec.ts
Docs have been added / updated (for bug fixes / features)
I’ve added documentation throughout the feature and also included a GUIDE file.
PR Type
What kind of change does this PR introduce?
What is the current behavior?
The
@angular/arialibrary currently lacks a Disclosure (Show/Hide) pattern implementation.What is the new behavior?
Implements the Disclosure Pattern with two directives:
DisclosureTrigger (
ngDisclosureTrigger)EnterandSpaceto toggle[(expanded)]disabledandalwaysExpandedstatesrole="button",aria-expanded,aria-controls,aria-disabledDisclosureContent (
ngDisclosureContent)DeferredContentAwarefor lazy renderingpreserveContentto keep DOM when collapsedhiddenattribute managementArchitecture
Follows the two-layer pattern established in
@angular/aria:DisclosurePatternclass insrc/aria/private/disclosure/src/aria/disclosure/Testing
runAccessibilityChecks()Documentation
guides/aria-disclosure.mdwith usage examples (Im not sure about location of this one, as they are not other patterns in this directory, but i could not find a better place)Does this PR introduce a breaking change?
Local Testing
Tested locally by linking packages via
file:protocol:{ "@angular/cdk": "file:/home/adrian-romanski/projects/components/dist/releases/cdk", "@angular/aria": "file:/home/adrian-romanski/projects/components/dist/releases/aria", "@angular/material": "file:/home/adrian-romanski/projects/components/dist/releases/material" }Verified:
aria-expanded,aria-controls,aria-disabled)[(expanded)]alwaysExpandedconstrainthiddenattribute)Build & Tests:
Other information
When to use Disclosure vs Accordion
ngAccordionGroupmultiExpandable)Example Usage