8000 `getByRole` doesn't respect `inert` when searching with `hidden: true` · Issue #665 · testing-library/jest-dom · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

getByRole doesn't respect inert when searching with hidden: true #665

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

Open
imaspen opened this issue Mar 11, 2025 · 0 comments
Open

getByRole doesn't respect inert when searching with hidden: true #665

imaspen opened this issue Mar 11, 2025 · 0 comments

Comments

@imaspen
Copy link
imaspen commented Mar 11, 2025
  • @testing-library/jest-dom version: 6.6.3
  • node version: 22.14.0
  • vitest version: 3.0.8
  • yarn version: 4.7.0

Relevant code or config:

<div role="region" aria-label="inert demo" inert></div>
expect(
  queryByRole("region", { name: "inert demo", hidden: false })
).not.toBeInTheDocument();

What you did:

Testing for an element not to be in the accessibility tree based on the presence of the inert attribute.

What happened:

getByRole returned the element, even though it should be hidden from the accessibility tree.

Reproduction:

https://codesandbox.io/p/devbox/react-testing-library-demo-forked-tg8knk

Problem description:

Elements with the inert attribute set should not be in the accessibility tree, as per the HTML standard.

Inert nodes generally cannot be focused, and user agents do not expose the inert nodes to accessibility APIs or assistive technologies.

Suggested solution:

TBD

@imaspen imaspen changed the title getByRole doesn't respect inert when searching with hidden: true getByRole doesn't respect inert when searching with hidden: true Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0