fix: make `Graph.options` truly per-instance by tbouffard · Pull Request #751 · maxGraph/maxGraph
Before, setting `Graph.options.foldingEnabled = false` on one `Graph` instance affected other instances too — because the `options` object was shared between them. For example, switching to the Constituent story (which disables `Graph.options.foldingEnabled`) then back to another story relying on the default (`true`) would break folding: the folding icon disappeared and cells couldn't be collapsed anymore. This could be seen with the `Collapse` and the `Folding` stories. The bug exists at least as of version 0.14.0, but probably from the first version of maxGraph. 🔍 Root cause: `options` was defined via mixins as an object, but the internal `applyMixin` function probably copies object references, not values — effectively making `Graph.options` global. ✅ Fix: move the `options` property directly onto the `Graph` class. It's the only object-typed prop in our mixins, and we're planning to turn `FoldingMixin` into a plugin anyway — so this fix is simple and future-proof. ℹ️ No impact for users, just internal code structure changes. In addition, migrate Constituent.stories.js to TypeScript to ease future maintenance.
tbouffard
marked this pull request as ready for review
tbouffard
changed the title
fix(graph): make
fix: make Graph.options truly per-instanceGraph.options truly per-instance
tbouffard
deleted the
fix/side_effect_when_changing_Graph_options
branch
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