Skip to content

refactor(joint-react): drop Paper width/height props — CSS-only sizing#3312

Merged
kumilingus merged 3 commits into
clientIO:devfrom
kumilingus:feat/paper-css-only-sizing
May 15, 2026
Merged

refactor(joint-react): drop Paper width/height props — CSS-only sizing#3312
kumilingus merged 3 commits into
clientIO:devfrom
kumilingus:feat/paper-css-only-sizing

Conversation

@kumilingus
Copy link
Copy Markdown
Contributor

Summary

  • <Paper> no longer exposes width / height props — they were a redundant alias for setting inline CSS on the host (dia.Paper.setDimensions writes \$el.css({ width, height }) at Paper.mjs:2286-2296) that conflicted with style / className on the same DOM element.
  • useCreatePortalPaper forces width: undefined, height: undefined into the dia.Paper constructor options so prototype defaults (800 / 600) get clobbered → paper.getComputedSize() (Paper.mjs:2263-2271) falls back to el.clientWidth / el.clientHeight. Host = CSS-sized, SVG = fills host.
  • Dropped the width / height prop sync useEffect (no longer needed).
  • Migrated every <Paper width={N} height={M}> callsite in stories / tests / demos / tutorials / the storybook decorator to <Paper style={{ width: N, height: M }}>.

Why

Two sources of truth (width / height props vs style.width/height / className CSS) both terminated in the same DOM property. Removing the props collapses to a single mechanism.

This change is a prerequisite for the companion @joint/react-plus PR that introduces PaperScroller-owned sheetWidth / sheetHeight.

Test plan

  • yarn workspace @joint/react typecheck
  • yarn workspace @joint/react jest
  • yarn workspace @joint/react storybook — spot-check that demos/examples still render at their previous sizes (now via style).
  • Confirm CSS-only Paper renders correctly in real DOM (intrinsic SVG fills host).

🤖 Generated with Claude Code

kumilingus and others added 3 commits May 14, 2026 22:12
`<Paper>` no longer accepts `width` / `height` props. These were a redundant
way to set inline CSS on the host (`dia.Paper.setDimensions` writes
`$el.css({ width, height })` at the end), conflicting with `style` /
`className` on the same element.

Now the host element is sized exclusively by CSS:
- `useCreatePortalPaper` forces `width: undefined, height: undefined` into
  the `dia.Paper` constructor options so prototype defaults (800/600) are
  clobbered → `paper.getComputedSize()` falls back to
  `el.clientWidth/clientHeight`.
- The dedicated `setDimensions` sync effect on prop change is gone.

All Paper callsites migrated from `<Paper width={N} height={M}>` to
`<Paper style={{ width: N, height: M }}>` (stories, tests, demos,
tutorials, the storybook decorator).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`getFitToContentArea` previously hard-anchored its grid at (0, 0): grid
lines fell at `0, gridWidth, 2*gridWidth, …`. New `originX` / `originY`
options (default `0`, paper-local coords) shift the anchor so grid
lines land at `originX + n*gridWidth, originY + m*gridHeight` instead.

Backward compatible — omitting the new opts reproduces today's behavior
exactly. `paper.fitToContent` already forwards `opt` through, so it
inherits the feature automatically.

Tested via `paper.fitToContent()` with a few combinations of
`allowNewOrigin` × non-zero origin.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@kumilingus kumilingus merged commit 2544f31 into clientIO:dev May 15, 2026
@kumilingus kumilingus deleted the feat/paper-css-only-sizing branch May 15, 2026 10:47
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.

1 participant