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

Conversation

koddsson
Copy link
Contributor

@koddsson koddsson commented Mar 8, 2022

Consider a element as hidden if it's in a closed <details> element.

Closes #77

@koddsson koddsson requested a review from a team as a code owner March 8, 2022 17:20
@@ -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.

Copy link
Member

@keithamus keithamus left a comment

Choose a reason for hiding this comment

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

Nice!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test for managing focus is failing
3 participants