Repository navigation
fix(datetime): keep month when calendar is hidden - #31711
Open
officialasishkumar wants to merge 1 commit into
Open
officialasishkumar wants to merge 1 commit into
officialasishkumar wants to merge 1 commit into
Conversation
Skip month detection in the calendar scroll listener when the calendar body has no layout, which is the case while the month/year picker is open or the host is hidden. Every box measures 0 then, which the listener read as having scrolled to the previous month, so opening the picker right after a scroll could move the month back. Force-rendered months still go through, as animateToDate waits on the listener to finish. Skipping them would leave forceRenderDate set and make every later scroll commit that stale date. closes ionic-team#31416
|
@officialasishkumar is attempting to deploy a commit to the Ionic Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
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: resolves #31416
What is the current behavior?
The calendar's scroll listener runs on a short debounce. If the month/year picker opens in that window, the listener runs while the calendar body is
display: none. Every box then measures 0, which the listener reads as having scrolled to the previous month, so the month moves back by one.What is the new behavior?
getChangedMonthreturns early when the calendar body has no layout, so hiding and showing the grid leaves the month untouched.animateToDatewaits on the listener to finish, so skipping them would leaveforceRenderDateset and make every later scroll commit that stale date.Does this introduce a breaking change?
Other information
This is the guard suggested in the issue and confirmed in the triage comment.
The tests dispatch the
scrollevent themselves, because the real timing is intermittent. I checked them against both failure modes in Chromium:March 2026instead ofApril 2026).forceRenderDatetest fails (April 2026instead ofJune 2026).With the fix, the tests pass in Chromium, Firefox and WebKit. So does a temporary test of the issue's real click sequence (month arrows, then the header straight away), which isn't part of this PR.
In a wider Chromium run of the
datetimeanddatetime-buttone2e suites with snapshots ignored, the only failures were outside this change.datetime/test/basic:818has an un-awaitedevaluatethat fails withTest ended.datetime/test/custom:371anddatetime/test/values:46failed once under load and passed 3 of 3 when rerun alone. I didn't compare snapshots.