Fix #5014: roll back default-date staging when Picker is cancelled on first open#5017
Merged
Merged
Conversation
… first open The default-date support added in RFE #4973 stages the resolved default into Picker.value via applyDefaultDateIfNeeded() so the show paths can display it. The Cancel-restore snapshot in showInteractionDialog ran *after* that staging, so a Cancel on the first open restored the leaked default into value - flipping the picker text from "..." to today's date and making subsequent getDate() / setDate(null) behavior look as if the user had committed. The same leak existed silently in the native picker and synchronous heavyweight Dialog branches. Take the snapshot in actionPerformed before applyDefaultDateIfNeeded runs, and add the matching cancel-time rollback in the native picker branch and the heavyweight Dialog PICKER_TYPE_DATE / DATE_AND_TIME cases. The existing custom-button cancel rollback (#4897) still works because both snapshots are now sourced from the same earlier capture. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
✅ Continuous Quality ReportTest & Coverage
Static Analysis
Generated automatically by the PR CI workflow. |
Collaborator
Author
|
Compared 110 screenshots: 110 matched. Native Android coverage
✅ Native Android screenshot tests passed. Native Android coverage
Benchmark ResultsDetailed Performance Metrics
|
Collaborator
Author
|
Compared 110 screenshots: 110 matched. Benchmark Results
Build and Run Timing
Detailed Performance Metrics
|
Collaborator
Author
|
Compared 108 screenshots: 108 matched. Benchmark Results
Build and Run Timing
Detailed Performance Metrics
|
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.
Summary
Picker.setDefaultDate(...)installed, tapping the picker and pressing Cancel on the first open was leaking the resolved default intovalue, flipping the displayed text from"..."to today's date and makinggetDate()return as if the user had committed. Re-opening then dismissing worked correctly because the second snapshot already held a "real" value.actionPerformedcallsapplyDefaultDateIfNeeded()(which mutatesvalueto the resolved default) beforeshowInteractionDialog's Cancel-restore snapshot ran — so the snapshot captured the post-staging value and Cancel "restored" it back to itself. Same silent leak existed in the native picker and synchronous heavyweightDialogcancel paths.actionPerformedbeforeapplyDefaultDateIfNeeded(). Remove the now-redundant snapshot fromshowInteractionDialog. Add matching cancel-time rollback to the native branch and toPICKER_TYPE_DATE/PICKER_TYPE_DATE_AND_TIMEcases in the heavyweightDialogelse branch.cancelAfterCustomButtonRollsBackExplicitFlag) continues to work because both snapshots are now sourced from the same earlier capture.Test plan
PickerDefaultDateTest#cancelOnFirstOpenKeepsPlaceholderAndDoesNotPinValuemirroring the repro:setDefaultDate(getter)→setType(DATE)→setDate(null)→ tap → Cancel; assertsgetText()is still"..."and that subsequentgetDate()resolves through an updated getter (i.e. nothing was pinned).PickerDefaultDateTest— 11/11 pass (10 pre-existing + 1 new).PickerComponentTest(5),PickerDefaultDateTest(11),PickerTest(2),Picker3Test(1),PickerCoverageTest(10),PickerDateTimeTest(1).🤖 Generated with Claude Code