fix: support inert attribute and <search> element in role queries#1376
Open
mixelburg wants to merge 1 commit intotesting-library:mainfrom
Open
fix: support inert attribute and <search> element in role queries#1376mixelburg wants to merge 1 commit intotesting-library:mainfrom
mixelburg wants to merge 1 commit intotesting-library:mainfrom
Conversation
- Add inert attribute check to isSubtreeInaccessible, so elements inside inert subtrees are correctly excluded from the a11y tree. Fixes testing-library#1364. - Add <search> element implicit role mapping (search), since aria-query 5.3.0 does not yet include this HTML-ARIA mapping. Fixes testing-library#1359.
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 7451bae:
|
|
Nice! I think I'll have a use case for this soon so might try it out via patching the main package |
|
Although have you seen the history on #1366? @eps1lon had some concerns about how That said, for my use case this will probably be fine, so I'll probably still apply the patch. |
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.
Summary
This PR addresses two related issues in role-based queries:
1.
inertattribute not hiding elements from a11y tree (#1364)Elements with the
inertattribute (and their descendants) should be excluded from the accessibility tree. Per the HTML spec,inertmakes the element and all its contents hidden from assistive technologies.Fix: Added a check in
isSubtreeInaccessiblethat returnstruewhen:inertattribute, ORinertattribute (viaelement.closest('[inert]'))2.
<search>element not found bygetByRole('search')(#1359)The
<search>HTML element has an implicit ARIA role ofsearchper the HTML-ARIA spec, butaria-query@5.3.0does not include this mapping in itselementRolesmap.Fix: Added a fallback in
getImplicitAriaRolesthat returns[search]for<search>elements. This workaround can be removed oncearia-querypublishes a version that includes this mapping (the mapping exists in aria-query'smainbranch but is not yet released).Test plan
<div inert />to the existingshouldExcludeFromA11yTreetest matrix<search>element implicit role29 passed, 29 totalRelated issues
getByRole('search')does not find<search />#1359