user-event
user-event copied to clipboard
respect elements that are hidden by <details>
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 theopen
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 adetails
element. thesummary
element acts as an [always visible] trigger for controlling the expanded state of thedetails
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
- [x] Tests
- [x] Ready to be merged