-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
MudExpansionPanel: Add toggle keyboard hotkeys, Add ability to remove content from DOM #11531
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
MudExpansionPanel: Add toggle keyboard hotkeys, Add ability to remove content from DOM #11531
Conversation
fix(MudExpansionPanel): improve accessibility for keyboard and mouse interaction - Makes header focusable and responsive to Enter/Space keys - Prevents tab navigation into collapsed panel content - Aligns behavior with accessibility standards (WCAG) Tested locally in MudBlazor.Docs to confirm behaviour across input methods.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #11531 +/- ##
==========================================
+ Coverage 91.18% 91.20% +0.01%
==========================================
Files 466 466
Lines 14652 14687 +35
Branches 2847 2855 +8
==========================================
+ Hits 13361 13395 +34
Misses 646 646
- Partials 645 646 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
src/MudBlazor/Components/ExpansionPanel/MudExpansionPanel.razor
Outdated
Show resolved
Hide resolved
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.
Keyboard accessibility is always needed! Just some things to tweak
src/MudBlazor/Components/ExpansionPanel/MudExpansionPanel.razor
Outdated
Show resolved
Hide resolved
src/MudBlazor/Components/ExpansionPanel/MudExpansionPanel.razor
Outdated
Show resolved
Hide resolved
…d optional content removal - Prevented focus and keyboard interaction on disabled panel headers by conditionally omitting tabindex - Introduced `RemoveContentOnCollapse` parameter to optionally remove panel content from the DOM when collapsed - Default behaviour retains content to preserve component state and avoid breaking changes - Added `hidden` and `aria-hidden` attributes to hide content from accessibility tree while keeping it mounted
src/MudBlazor/Components/ExpansionPanel/MudExpansionPanel.razor.cs
Outdated
Show resolved
Hide resolved
src/MudBlazor/Components/ExpansionPanel/MudExpansionPanel.razor
Outdated
Show resolved
Hide resolved
src/MudBlazor/Components/ExpansionPanel/MudExpansionPanel.razor
Outdated
Show resolved
Hide resolved
src/MudBlazor/Components/ExpansionPanel/MudExpansionPanel.razor.cs
Outdated
Show resolved
Hide resolved
Aria hidden removed Flipped bool similar to MudTabs
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.
Awesome! Could you add some HandleKeyDownAsync and KeepContentAlive tests to finish it off? (also small thing but its back to tabs in the razor)
…ssibility features - Add keyboard navigation tests for Enter/Space key toggling - Test accessibility behavior with hidden attribute for collapsed content - Add HandleKeyDownAsync tests for disabled state and non-trigger keys - Add KeepContentAlive tests for content rendering lifecycle - Verify proper interaction between KeepContentAlive and accessibility states MudExpansionPanel updated to spaces
|
Hey, tests added! Hope they're ok, and updated the files back to spaces |
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.
Great work!
fix(MudExpansionPanel): improve accessibility for keyboard and mouse interaction
Tested locally in MudBlazor.Docs to confirm behaviour across input methods.
Description
This PR enhances accessibility in
MudExpansionPanel
when using customTitleContent
. The default behavior does not support keyboard interaction or proper focus handling, particularly when the panel is collapsed. This results in users being unable to toggle the panel via keyboard or inadvertently tabbing into visually hidden content.Changes include:
Enter
andSpace
These changes improve usability for keyboard and screen reader users and follow accessibility best practices.
How Has This Been Tested?
Tested locally by running the MudBlazor docs site using the edited source code:
Tab
,Enter
, andSpace
Type of Changes
Checklist
dev
).Related Issues