fix(picker): stage setX during lightweight popup and roll back on Cancel#4923
Merged
Conversation
Follow-up to #4897: custom popup buttons that mutate the picker mid-edit (e.g. "+7 days" calling setDate(getDate() + 7d)) wrote the staged value straight into the committed `value` field. If the user then dismissed the popup with Cancel, getDate() returned the staged value instead of the date the picker held before editing began, leaking the unwanted change into the picker. Snapshot `value` into a new preEditValue field at the moment the lightweight popup is shown, then roll back to it in endEditing when the user presses Cancel. Done / Next / Prev still commit the wheel value as before, and clear the snapshot on the way out. Native pickers are unchanged - they are read-only while shown, which the existing setter Javadocs already call out; the new staging semantics only apply to the lightweight popup. Adds PickerCancelRestoreTest: drives a Picker with a "+7 Days" custom button programmatically, asserts that Cancel restores the pre-edit date and that Done commits the staged date. Registered in Cn1ssDeviceRunner alongside the existing lightweight-picker tests. 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 105 screenshots: 105 matched. Benchmark Results
Build and Run Timing
Detailed Performance Metrics
|
…ts own popup The follow-up cancel/done test caught a pre-existing bug exposed once the popup was reopened after a Cancel. endEditing nulls Picker's local currentInput field but leaves Form.currentInputDevice pointing at the just-disposed VirtualInputDevice. When the next showInteractionDialog reassigns Picker.currentSpinner to the freshly created spinner and calls Form.setCurrentInputDevice(newInput), the form synchronously calls close() on the OLD VirtualInputDevice -- whose close() was unconditionally setting currentSpinner = null. That clobbered the new popup's live wheel reference, so setX calls from custom buttons no longer propagated and Done committed the spinner's initial value. Capture the spinner in registerAsInputDevice and only null currentSpinner / currentInput in close() when they still point at THIS popup, mirroring the same compare-then-null pattern endEditing already uses. Single-popup flows (initial open, Done, Cancel, stopEditing) are unaffected because the fields still match THIS device when close() fires. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
Compared 105 screenshots: 105 matched. Native Android coverage
✅ Native Android screenshot tests passed. Native Android coverage
Benchmark ResultsDetailed Performance Metrics
|
Collaborator
Author
|
Compared 105 screenshots: 105 matched. Benchmark Results
Build and Run Timing
Detailed Performance Metrics
|
…che hit The cache key was fixed at v1 while npm install playwright resolves the floating latest. When Playwright shipped a new chromium build between runs, the cached browser binary stayed at the older revision but the freshly installed Playwright pointed at a path that didn't exist (chromium_headless_shell-1223/...), so every CI run since the drift failed with "browserType.launch: Executable doesn't exist" before any test could start. Always run `npx playwright install chromium` after npm install. It's a no-op when the cached binary matches and re-downloads when versions drift, so the workflow self-heals on the next Playwright bump. OS deps still install unconditionally (they were never cached). Bumps the cache key to v2 so the bad entry gets rebuilt instead of restored. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
Compared 15 screenshots: 15 matched. |
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
+7 Daysaction callingsetDate(getDate() + 7d)) wrote the staged value directly into the committedvaluefield. Pressing Cancel then leaked that value into the picker instead of rolling back to the date the picker held before editing began.valueinto a newpreEditValuefield when the lightweight popup is shown, and roll back to it inendEditingwhen the user presses Cancel. Done / Next / Prev still commit the wheel value as before and clear the snapshot on the way out.setDate,setTime,setDuration,setSelectedString,setSelectedStringIndex) updated to describe the staging behavior.Test plan
PickerCancelRestoreTestdrives aPickerwith a+7 Dayscustom button programmatically: opens the popup, clicks the button, then clicks Cancel and assertsgetDate()returns the pre-edit date. Repeats with Done and asserts the staged date is committed. Registered inCn1ssDeviceRunner.LightweightPickerButtonsScreenshotTestcontinues to exercise the live wheel propagation from RFE: Add method to Picker to get or update internal value based on the Picker scroll wheel positions set by the user #4897 (verified by walking the test flow —stopEditingdoesn't go through the cancel path, so the staged wheel value still drives the screenshot).🤖 Generated with Claude Code