Skip to content

fix(datetime): tear down ready state when an overlay dismisses - #31335

Open
ShaneK wants to merge 2 commits into
mainfrom
fix/31155
Open

fix(datetime): tear down ready state when an overlay dismisses#31335
ShaneK wants to merge 2 commits into
mainfrom
fix/31155

Conversation

@ShaneK

@ShaneK ShaneK commented Aug 6, 2026

Copy link
Copy Markdown
Member

Issue number: resolves #31155, resolves #31143


What is the current behavior?

Currently, an ion-datetime inside a modal or popover shows the wrong month once the overlay is reopened. The selected day isn't visible, the previous month button does nothing, and picking a day from the grid lands on an unrelated date.

Overlays move their host element into ion-app when presenting and back to its original position when dismissing, which disconnects and reconnects the datetime. disconnectedCallback reset hasBeenIntersecting during that move, so by the time the hidden-state IntersectionObserver entry arrived, hiddenCallback mistook the dismissal for the synthetic initial entry and returned early. That left datetime-ready on the host, so on the next present markReady saw the class and returned without re-centering the calendar on the working month, and the browser had already reset scrollLeft to 0 while the overlay was hidden. scrollLeft: 0 renders the previous month's grid while the header still names the working month, which is what produces all three symptoms.

What is the new behavior?

With this change, disconnectedCallback no longer resets hasBeenIntersecting. That flag tracks the observers, and the observers are only created in componentDidLoad and never re-created on reconnect, so a DOM move has no business clearing it. hiddenCallback now sees the real hidden transition on dismiss and tears down as it did before #31108, which lets markReady run again on the next present and re-center the calendar.

Does this introduce a breaking change?

  • Yes
  • No

Other information

This regression was introduced in #31108. That PR needed the flag to make hiddenCallback ignore the synthetic initial entry, but the disconnectedCallback reset it also added had no job and broke the overlay case. Before #31108, hiddenCallback had no guard at all and always removed datetime-ready on dismiss, so this restores the behavior that shipped for all of v8..

To reproduce: open the "Modal - Default" picker, dismiss it, then open it again. On main the grid shows February while the header reads March 2022.

@ShaneK
ShaneK requested a review from a team as a code owner August 6, 2026 17:35
@ShaneK
ShaneK requested a review from brandyscarney August 6, 2026 17:35
@vercel

vercel Bot commented Aug 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ionic-framework Ready Ready Preview Aug 7, 2026 1:29pm

Request Review

Mostly doing this here to force GitHub to recheck the branch (it has broken checks right now that I can't re-trigger)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: core @ionic/core package

Projects

None yet

1 participant