diff --git a/CHANGELOG.md b/CHANGELOG.md index 65abbd3d00..03790601eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Note: Safari 15, Chrome 56, Firefox 51 and later are now required for map traces - Update `hex_to_rgb` function to raise error for invalid-length hex codes, and emit warning for hex codes containing alpha [[#5729](https://github.com/plotly/plotly.py/pull/5729)], with thanks to @dylanpulver for the contribution! +### Fixed +- Fix `FigureWidget` state synchronization bug where frontend modifications to array properties (like `layout.shapes`) failed to properly update the Python property cache and occasionally surfaced `Undefined` objects [[#5689](https://github.com/plotly/plotly.py/issues/5689)] + ## [7.0.0] - 2026-08-25 ### Fixed diff --git a/plotly/basedatatypes.py b/plotly/basedatatypes.py index d81ba0950c..121ae52b73 100644 --- a/plotly/basedatatypes.py +++ b/plotly/basedatatypes.py @@ -5458,6 +5458,16 @@ def _dispatch_change_callbacks(self, changed_paths): ------- None """ + # Invalidate cache for changed compound array properties so that they are + # reconstructed from the underlying properties dictionary on the next access. + # We only pop from _compound_array_props because compound arrays are immutable + # tuples that must be rebuilt to reflect added or removed elements. + for path in changed_paths: + if len(path) > 0: + prop = path[0] + if prop in self._compound_array_props: + self._compound_array_props.pop(prop, None) + # Loop over registered callbacks # ------------------------------ for prop_path_tuples, callbacks in self._change_callbacks.items():