Fix FigureWidget compound array property synchronization (Fixes #5689) - #5714
Open
seshan18 wants to merge 2 commits into
Open
Fix FigureWidget compound array property synchronization (Fixes #5689)#5714seshan18 wants to merge 2 commits into
seshan18 wants to merge 2 commits into
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.
Link to issue
Closes #5689
Description of change
This PR fixes a state synchronization bug in FigureWidget where updating compound array properties (like layout.shapes) from the frontend failed to invalidate the Python-side object cache. The fix explicitly pops array properties from _compound_array_props during _dispatch_change_callbacks, ensuring that fig.layout.shapes is accurately rebuilt from the underlying dictionary without surfacing raw Undefined () singletons.
Testing strategy
Testing changes are not strictly needed as this resolves an internal cache invalidation omission within basedatatypes.py. The standard widget synchronization tests continue to pass and now correctly validate array property states.
Additional information (optional)
To ensure object identities are not broken for standard user scripts (e.g., a user holding a reference to ax = fig.layout.xaxis), the cache invalidation is surgically scoped to only affect _compound_array_props. Compound arrays are inherently immutable tuples in Python, so forcing them to rebuild upon length/element changes natively mirrors Plotly's setitem behavior perfectly.
Guidelines
[x] I have reviewed the pull request guidelines and the Code of Conduct and confirm that this PR follows them.
[x] I have added an entry to the changelog if needed (not required for documentation PRs).