Skip to content

Validate imperative layout changes against the group's current size - #772

Merged
bvaughn merged 2 commits into
mainfrom
bvaughn/bug-fix-770
Oct 20, 2026
Merged

bvaughn merged 2 commits into
mainfrom
bvaughn/bug-fix-770

Conversation

@bvaughn

@bvaughn bvaughn commented Oct 20, 2026

Copy link
Copy Markdown
Owner

Pixel-based constraints (e.g. minSize="200px") are converted to percentages using the group size that the group's ResizeObserver last measured. If the group was resized and an imperative method ran before that observer did (e.g. from an application's own ResizeObserver), the layout was validated against the old size's constraints. The clamped result was then saved as the requested layout, so it stayed wrong after the observer ran.

The fix:

  • Moved the ResizeObserver's sync step into a new syncAxisStateToCurrentSize() helper. It measures the group, recalculates the pixel-based constraints, and re-derives the layout from the requested layout. It returns the new state without saving it.
  • The observer and the imperative methods above now use the helper. Imperative methods sync before validating, and save the synced state and their own change together, so onLayoutChange fires once per call.
  • calculateItemConstraints() accepts an already-measured size, so each sync measures the panels once.

Behavior changes:

  • An imperative call on a group that has grown since its observer last ran now sees the current size.
  • If a group was hidden at mount and becomes visible before its observer runs, setLayout() now applies the layout instead of ignoring it.
  • Panel.resize() on a hidden group now uses the last measured size instead of dividing by zero.

Note

Each imperative call now reads the panels' offsetWidth/offsetHeight once. This can make the browser recalculate layout if a change is pending.

Fixes #770

@vercel

vercel Bot commented Oct 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
react-resizable-panels Ready Ready Preview Oct 20, 2026 10:48pm UTC

@bvaughn
bvaughn merged commit 625ef2d into main Oct 20, 2026
7 checks passed

This branch was successfully deployed

1 active deployment
Preview — 97c0c86e Deployed Oct 20, 2026 by vercel[bot]
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.

setLayout() validates against pixel constraints derived from the group's previous size if the group resized before the library's ResizeObserver ran

1 participant