Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

respect elements that are hidden by <details> #1165

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
VinceMalone wants to merge 1 commit into testing-library:main
base: main
Choose a base branch
Loading
from VinceMalone:hidden-details

Conversation

@VinceMalone
Copy link
Contributor

@VinceMalone VinceMalone commented Sep 15, 2023

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

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

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /