Skip to content
This repository has been archived by the owner on Sep 22, 2022. It is now read-only.

Check if elements is in a closed details element #81

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function focusable(el: Target): boolean {
function visible(el: Target): boolean {
return (
!el.hidden &&
!el.closest('details:not([open])') &&
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first summary in a details would actually be shown so we probably need something like:

Suggested change
!el.closest('details:not([open])') &&
!(el instanceof HTMLSummaryElement && el.closest('details:not([open])')) &&

But we need to make sure to test this.

(!(el as Disableable).type || (el as Disableable).type !== 'hidden') &&
(el.offsetWidth > 0 || el.offsetHeight > 0)
)
Expand Down
2 changes: 1 addition & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe('details-dialog-element', function() {
assert(!details.open)
})

it.skip('manages focus', async function() {
it('manages focus', async function() {
summary.click()
await waitForToggleEvent(details)
assert.equal(document.activeElement, dialog)
Expand Down