fix(datetime): prevent hidden-state observer from tearing down ready class on initial entry#31108
Conversation
…class on initial entry
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue number: internal
What is the current behavior?
ion-datetimeruns two IntersectionObservers: one to detect when the host becomes visible (which addsdatetime-ready) and one to detect when it becomes hidden (which removes the class and tears down listeners). When the host mounts offscreen, both observers receive an initial "not intersecting" entry onobserve(). The hidden-state observer treats that initial entry as a real visible-to-hidden transition, queues awriteTaskto removedatetime-ready, and races the layout-based fallback (ensureReadyIfVisible) that adds the class after 100ms. On WebKit the remove wins often enough that the e2e test for the fallback (added in #30793 to fix #30706) had to be skipped on Mobile Safari. Anything in production that addsdatetime-readyoutside of a realisIntersecting: trueevent is exposed to the same race.What is the new behavior?
A
hasBeenIntersectingflag is set true only whenvisibleCallbackobservesisIntersecting: true. The hidden-state observer's teardown is gated on this flag, so the synthetic initial "not intersecting" entry is ignored. The flag is reset when the host actually transitions to hidden and ondisconnectedCallback. The previously duplicated init-listeners + ready-class block is consolidated into a singlemarkReadyhelper. The WebKit skip on the IO-fallback e2e test has been removed.Does this introduce a breaking change?
Other information
The asymmetry where
ensureReadyIfVisible(the layout fallback) deliberately does NOT sethasBeenIntersectingis load-bearing: the flag must reflect a real observer signal, not a fallback-driven write, otherwise the bug returns. This is called out at the guard site so future cleanups don't undo it.This test was most likely to fail in docker testing Linux Webkit with
--repeat-each=20because it was pretty flaky. I was able to force it to fail under these conditions and, after fixing it, it no longer failed.Relevant Preview Link: