feat(aria/disclosure): add disclosure pattern #32704
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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