Fix dropdown field change API to sync selection with model updates#309
Open
vivekjyani wants to merge 2 commits intomainfrom
Open
Fix dropdown field change API to sync selection with model updates#309vivekjyani wants to merge 2 commits intomainfrom
vivekjyani wants to merge 2 commits intomainfrom
Conversation
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.
Context / Spec
When a dropdown field value is updated externally via the change API (for example, programmatic model updates or mirrored-field updates),
DropdownViewcould show stale selection state because its internal@State(selectedDropdownValueID) only captured the initial model value.Ticket: NO-2072
What Changed
1) State sync fix in
DropdownViewFile:
Sources/JoyfillUI/View/Fields/DropdownView.swiftAdded an observer to sync internal selection state whenever
dropdownDataModel.dropdownValuechanges externally:The guard prevents redundant writes and avoids re-triggering the existing
onChangeflow unnecessarily.2) UI regression test for mirrored dropdown behavior
File:
JoyfillSwiftUIExample/JoyfillUITests/ChangeUITests/OnChangeHandlerUITests.swiftAdded
testDropdownCoordinatess()(iPad-only) that:"No"in the left dropdown,This validates that external/model-driven dropdown updates are now reflected in UI state.
Design Decisions
.onChangeon model value? It is the minimal fix that preserves current architecture while correctly re-syncing local@Stateon external updates.Public API Impact
No public API changes. This is an internal state-sync and test coverage update.
Test Coverage
Added UI coverage via:
testDropdownCoordinatess()inOnChangeHandlerUITestsReviewer Notes
@Stateinitialized ininitdoes not automatically track subsequent model updates.