Skip to content
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

respect elements that are hidden by <details> #1165

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

VinceMalone
Copy link

What:

stop considering elements hidden by a collapsed <details> element to be visible or focusable, via getTabDestination().

for example, user.tab() should not focus elements hidden by a collapsed details ancestor.

Why:

same reasons for how .toBeVisible works in jest-dom

An element is visible if all the following conditions are met:

  • […]
  • if <details /> it has the open attribute

given the following code:

<details>
  <button id="hidden"></button>
</details>
<details open>
  <button id="visible"></button>
</details>

button#hidden should not be considered visible, nor should it be focusable, but button#visible should.

Note
the single exception for this is a summary element that is a direct descendant of a details element. the summary element acts as an [always visible] trigger for controlling the expanded state of the details element.

How:

at least for conveniences sake, i copied the same logic from jest-dom for determining if an element should be considered visible when walking the element tree (with one exception: looking for the hidden attribute — this caused an issue that i think might be a bug in that library)

Checklist:

  • Documentation
  • Tests
  • Ready to be merged

@codesandbox-ci
Copy link

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 d510c45:

Sandbox Source
userEvent-dom Configuration
userEvent-react Configuration

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

Successfully merging this pull request may close these issues.

1 participant