Skip to content

fix(joint-core, joint-react): override gridPatterns via getGridPatterns() instead of mutating static property#3330

Merged
kumilingus merged 6 commits into
clientIO:devfrom
Geliogabalus:grid-patterns-override-dev
May 22, 2026
Merged

fix(joint-core, joint-react): override gridPatterns via getGridPatterns() instead of mutating static property#3330
kumilingus merged 6 commits into
clientIO:devfrom
Geliogabalus:grid-patterns-override-dev

Conversation

@Geliogabalus
Copy link
Copy Markdown
Contributor

Summary

  • Moves grid pattern color injection from a module-level mutation of `dia.Paper.gridPatterns` (static class property) into an overridable `getGridPatterns()` method on the Paper prototype
  • Adds `getGridPatterns(): Record<string, Paper.GridOptions[]>` as a protected method on `dia.Paper` and updates the TypeScript declaration accordingly
  • The `@joint/react` Paper preset overrides `getGridPatterns()` to substitute `--jj-paper-grid-color` into pattern colors at render time, rather than permanently mutating the shared static object

Motivation

The previous approach mutated `dia.Paper.gridPatterns` once at import time, making the CSS variable substitution permanent and side-effectful for any code that imported the preset. The new approach is non-destructive: each `GridLayerView` instantiation receives a fresh clone with the override applied, and the static property remains unmodified for downstream consumers.

Test plan

  • Verify grid renders correctly with the default dot/line/fixedDot/mesh/jump patterns
  • Confirm `--jj-paper-grid-color` CSS variable is respected by the grid layer
  • Confirm `dia.Paper.gridPatterns` static object is no longer mutated after importing the `@joint/react` preset
  • Check that subclassing `Paper` and overriding `getGridPatterns()` works as expected

🤖 Generated with Claude Code

@Geliogabalus Geliogabalus changed the base branch from master to dev May 22, 2026 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants