Skip to content

feat(joint-react): dev warning when resizing an auto-sized element#3386

Merged
kumilingus merged 1 commit into
clientIO:devfrom
kumilingus:feat/joint-react-warn-resize-auto-sized
Jun 24, 2026
Merged

feat(joint-react): dev warning when resizing an auto-sized element#3386
kumilingus merged 1 commit into
clientIO:devfrom
kumilingus:feat/joint-react-warn-resize-auto-sized

Conversation

@kumilingus

Copy link
Copy Markdown
Contributor

What

A dev-only console warning when an auto-sized element (rendered without useModelGeometry, so its size is measured from the React content) is resized by a tool (FreeTransform / Halo) or a direct cell.resize().

Such resizes are immediately overwritten by the measurement pipeline, so they silently do nothing — the handles drag but the box snaps back to its content size. The warning tells the consumer they likely forgot useModelGeometry.

How

GraphStore is the only place that owns both the graph (change:size events) and the size-observer registration (observer.has(id)) — the only reliable runtime signal that an element is in auto-size mode (useModelGeometry / StaticHTMLFrame elements are never registered).

  • utils/dev-warnings.ts — new warnResizeOnAutoSizedElement(cellId), warn-once (shared WARNED set), process.env.NODE_ENV === 'production' guard (tree-shaken in prod). Matches the existing warnUnstableSelector / warnDuplicatePapers style.
  • store/graph-store.ts — dev-only change:size listener: warns when !opt.autoSize && observer.has(cell.id). Measurement writes are flagged model.set(..., { autoSize: true }), so the pipeline's own writes are skipped. Detached in clean().

Covers FreeTransform, Halo, and programmatic resizes uniformly — no per-tool wiring, no exposed observer internals.

Tests (store/__tests__/graph-store.test.ts)

  • warns when an observed (auto-sized) element is resized externally; dedups on repeat
  • no warn for measurement-driven ({ autoSize: true }) writes
  • no warn for a non-auto-sized element (not registered with the observer)

Verification

  • yarn jest graph-store.test → 19 pass (3 new)
  • yarn typecheck clean, yarn lint clean

🤖 Generated with Claude Code

@kumilingus kumilingus requested a review from samuelgja June 22, 2026 21:28
An element rendered without `useModelGeometry` is auto-sized — its HTMLBox/
HTMLHost measures the React content and writes the size back to the model. A
tool resize (FreeTransform / Halo) or a direct `cell.resize()` is then
immediately overwritten by the measurement pipeline, so it silently has no
effect.

GraphStore now attaches a dev-only `change:size` listener: when a size change
carries no `autoSize` flag (i.e. it is not a measurement write) and the element
is currently registered with the size observer (auto-size mode), it warns once
per element via `warnResizeOnAutoSizedElement`. Tree-shaken in production;
detached in `clean()`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@kumilingus kumilingus force-pushed the feat/joint-react-warn-resize-auto-sized branch from e9b0f19 to f5a4b70 Compare June 23, 2026 11:24
@kumilingus kumilingus merged commit 9e81f3c into clientIO:dev Jun 24, 2026
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