fix(FocusTrap): resolve aria_hidden_nontabbable accessibility violation#8470
Open
Aryan3902 wants to merge 2 commits intoprimefaces:masterfrom
Open
fix(FocusTrap): resolve aria_hidden_nontabbable accessibility violation#8470Aryan3902 wants to merge 2 commits intoprimefaces:masterfrom
Aryan3902 wants to merge 2 commits intoprimefaces:masterfrom
Conversation
872c7e3 to
b7c8850
Compare
melloware
approved these changes
Jan 9, 2026
Member
|
it lokos like Primevue is doing the same thing: https://github.com/primefaces/primevue/blob/b83794d8f989321bd70196d9dd6b0e8cdeef547b/packages/primevue/src/focustrap/FocusTrap.js#L99-L108 |
Member
|
Assigned to @tugcekucukoglu to review since PrimeVue is doing the same thing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix #8365
The Issue
The focus guard elements (the hidden spans used to trap focus) were rendered with conflicting attributes: tabIndex="0" combined with aria-hidden="true" and role="presentation".
Reason
A focusable element (tabIndex="0") cannot be marked as hidden (aria-hidden="true") because it creates a state where focus lands on an element that technically "doesn't exist" in the accessibility tree.
The Fix
I have removed aria-hidden={true} and role={'presentation'} from the createFocusableElement helper.
These elements are technically focusable, so they must be exposed to the accessibility tree.
They remain visually hidden via the existing p-hidden-accessible CSS class.
The onFocus event handlers continue to function correctly, redirecting focus instantly without negatively impacting screen reader announcements.
How Has This Been Tested?
Automated Scan: Verified that the aria_hidden_nontabbable (Fail_1) error no longer appears in accessibility scans.
Functional Test: Verified that the focus trap still functions correctly (Focus loops back to the start when tabbing past the last element, and vice versa).
Visual Test: Confirmed no visual regression (the spans remain invisible).