Conversation
validateParts clamped the date first and then fixed a day that does not exist in the month. clampDate returns the minParts or maxParts object itself, so the day fix was written into the bound. Selecting the 31st and then a shorter month on the wheel moved max to the last day of that month, and the returned date could be past max. Fix the day first, then clamp, and copy the clamped result. Resolves ionic-team#29124 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
@breken-ai 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 #29124
What is the current behavior?
validateParts(core/src/components/datetime/utils/manipulation.ts) clamps the date to min/max first, then fixes a day that does not exist in the month.clampDatereturns theminParts/maxPartsobject itself, not a copy, so the day fix is written into the bound.With the repro from #29124 (
min="2024-03-01T00:00:00",max="2024-04-20T23:59:59"), selecting March 31 and then April on the month wheel callsvalidateParts({ month: 4, day: 31, year: 2024 }, min, max):clampDatereturnsthis.maxPartsnumDays(April) = 30 < 31, somaxParts.day = 30After that,
maxPartsis April 30, April 21 to 30 are no longer disabled, and the returned date (April 30) is past the real max. The same happens tominPartswhen the date is before min, e.g. February 31 withminin March setsminParts.dayto 29.What is the new behavior?
minParts/maxPartsare never changed.Unit tests in
manipulation.spec.tscover the max case from the issue, the min case, and the max time case.Red on
main(879e91d):Green with the fix:
npx stencil test --spec -- src/components/datetime/test/passes 116/116.eslint,prettier --checkandtsc --noEmit -p tsconfig.jsonare clean.Does this introduce a breaking change?
Other information
This fix was found and written with an AI coding assistant (Claude Code); the red/green runs above are from this branch.
🤖 Generated with Claude Code