MudTabs: Improve accessibility#11581
Conversation
- added role="tab", role="tabpanel" and role="tablist" attributes - implemented keyboard navigation (ArrowLeft, ArrowRight, Enter, Space) with manual activation - added tabindex handling for correct focus behaviour - added unit tests to validate keyboard navigation, attributes, and focus behaviour
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #11581 +/- ##
=======================================
Coverage 91.30% 91.30%
=======================================
Files 466 466
Lines 14709 14717 +8
Branches 2869 2869
=======================================
+ Hits 13430 13438 +8
Misses 636 636
Partials 643 643 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
danielchalmers
left a comment
There was a problem hiding this comment.
I need to test locally but always love to see more accessibility!
There's a number of formatting diffs, could you see if you can revert them so it's easier to review the real changes?
- Add stable ID generation for tabs and panels - Implement aria-controls and aria-labelledby attributes - Use panel index for indentification - Ensure bidirectional accessibility relationship between tabs and panels
versile2
left a comment
There was a problem hiding this comment.
Apart from the MudTabPanel needing the class/style/attributes this feels ready to go.
igotinfected
left a comment
There was a problem hiding this comment.
Appreciate your accessibility contribution!!
Added a few comments and tested the changes locally, some feedback:
- in the "scrollable list" example the scroll icons aren't updated when hitting the last page/item ("go right" button should disappear, "go left" button should appear) and sometimes the view doesn't scroll with the focus, such that the focused tab is out of view (local WASM docs test URL)
- in the "visibility" example, toggling the visibility of the second tab breaks keyboard navigation (switching focus between the visible tabs doesn't work as expected) (local WASM docs test URL)
- if you're up for it you could also implement the
Deleteshortcut for deletable tabs in this local WASM docs example) for example - in the "simple tabs" example the tab wrapper has an
aria-labelledbythat points to an element that doesn't exist, I believe this is something that should be user controlled if they provide a label for the tab component - pressing
Spaceto activate a tab makes the page jump, you can refer to MudCheckBox's implementation for how to fix that
Don't necessarily think any of these are blocking for the PR though!
…ync() an async task to resolve error
aria-controls, role, id, aria-selected, tabindex and onkeydown added to mudtabs indexing on the tabpanel updated to the fieldid public string made internal space tests added to tabtests, keeptabsnotalive test updated to pass
…reating a new string object every time it's called
fix(
MudTabs): improve accessibility for keyboard interactionTested locally in
MudBlazor.Docsto confirm behaviour across input methods.Description
This PR enhances keyboard accessibility in
MudTabsby implementing proper keyboard navigation and ARIA support. Previously, the tabs component lacked proper keyboard interaction patterns, making it difficult for keyboard and screen reader users to navigate between tabs effectively.Changes include:
role="tab",role="tablist",role="tabpanel", and aria-selected attributesNew Changes
aria-controls
How Has This Been Tested?
Tested locally by running the MudBlazor docs site using the edited source code:
Type of Changes
Checklist
dev).Related Issues