Sync ChartDetailView state with external valueElements updates#311
Open
vivekjyani wants to merge 4 commits intomainfrom
Open
Sync ChartDetailView state with external valueElements updates#311vivekjyani wants to merge 4 commits intomainfrom
vivekjyani wants to merge 4 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
NO-2078 —
ChartDetailViewcould get out of sync when chart updates were applied externally (change API, mirrored field updates, reset/recompute flows). The view initialized local@Stateonce and then did not reliably re-sync both value elements and axis coordinates from model updates.What Changed
1)
ChartDetailViewnow syncs both chart values and chart coordinates from model updatesFile:
Sources/JoyfillUI/View/Fields/ChartView/ChartDetailView.swiftchartCoordinatesDatasource to read fromchartDataModel.chartCoordinates..onChangesync forchartDataModel.valueElements-> localvalueElements..onChangesync forchartDataModel.chartCoordinates-> localchartCoordinatesData.2) External change payload now applies chart axis data through
DocumentEditorFiles:
Sources/JoyfillUI/ViewModels/DocumentEditor.swiftSources/JoyfillUI/ViewModels/DocumentEditor+Formulas.swiftIn
parseChanges, axis values (xTitle,yTitle,xMin,xMax,yMin,yMax) are read from the incoming change payload and assembled intoChartData.updateValue(...)now accepts optionalchartDataand, when present, updates the stored chart axis fields in the target field before refresh/dependency recalculation.3)
ChartDataModelnow carries axis data as a single coordinates objectFiles:
Sources/JoyfillUI/ViewModels/Models.swiftSources/JoyfillUI/ViewModels/DocumentEditor.swiftReplaced separate axis properties on
ChartDataModel(x/y title/min/max) with:chartCoordinates: ChartAxisConfiguration?Updated chart model construction in
DocumentEditorto populate this coordinates object from field data.4) Added UI regression coverage
File:
JoyfillSwiftUIExample/JoyfillUITests/ChangeUITests/OnChangeHandlerUITests.swiftAdded
testChartCoordinatess()to validate chart detail synchronization behavior across chart instances/pages by editing one chart configuration and asserting corresponding values are reflected in the paired chart UI.Design Decisions
.onChangesynchronization inChartDetailViewkeeps the existing local edit flow intact while correctly responding to external model updates.chartCoordinatesmodel property reduces drift risk vs passing six separate axis fields.chartDatainupdateValuekeeps non-chart update paths unchanged while enabling full chart updates when axis values are provided.Public API Impact
No external/public API changes. This PR updates internal view-model wiring and chart state synchronization behavior.
Test Coverage
Added UI test coverage:
testChartCoordinatess()inOnChangeHandlerUITestsReviewer Notes