Skip to content

Conversation

@knuton
Copy link
Member

@knuton knuton commented Nov 2, 2025

Element.checkVisibility() is now available in latest versions of all major browsers. Where it is not available, we can at least roughly approximate it by recursing up the DOM tree and checking for close analogues of the evaluated style properties.

This is a better check for whether elements should count as "visible" and able to receive focus, because it factors in visibility of ancestors. The check is cheap on modern browsers, older browsers have to pay a slightly bigger tax to determine visibility now.

https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility

image

@knuton knuton force-pushed the use-checkvisibility branch 5 times, most recently from dd157c2 to 28267ac Compare November 3, 2025 10:13
`Element.checkVisibility()` is now available in latest versions of all
major browsers. Where it is not available, we can at least roughly
approximate it by recursing up the DOM tree and checking for close
analogues of the evaluated style properties.

This also factors in the recent `content-visibility` CSS property where
supported and used.
@knuton knuton force-pushed the use-checkvisibility branch from 28267ac to 964a85d Compare November 3, 2025 10:26
@knuton knuton requested a review from yfyf November 3, 2025 10:29
@knuton knuton marked this pull request as ready for review November 3, 2025 10:29
Copy link
Contributor

@yfyf yfyf left a comment

Choose a reason for hiding this comment

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

Nicely done. Tested that this fixes the issues with exhausted event not firing I saw earlier on a bunch of "messy" websites and also in PlayOS settings. Also briefly checked that it doesn't change/break anything obvious in Play.

@knuton knuton merged commit b475f7b into dividat:main Nov 4, 2025
6 checks passed
@knuton knuton deleted the use-checkvisibility branch November 4, 2025 07:56
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.

2 participants