Skip to content

fix: maintain controlled pane sizes on container resize#869

Merged
tomkp merged 1 commit intomasterfrom
fix/controlled-mode-resize-868
Jan 12, 2026
Merged

fix: maintain controlled pane sizes on container resize#869
tomkp merged 1 commit intomasterfrom
fix/controlled-mode-resize-868

Conversation

@tomkp
Copy link
Copy Markdown
Owner

@tomkp tomkp commented Jan 12, 2026

Summary

Fixes #868

When using controlled mode with pixel sizes, panes were incorrectly being scaled proportionally when the container/window resized. This fix checks for controlled size props in handleContainerSizeChange and uses calculateInitialSizes instead of distributeSizes to maintain the fixed sizes from props.

Changes

  • Add hasControlledSizes check in handleContainerSizeChange
  • Use calculateInitialSizes for controlled panes on resize (maintains fixed pixel sizes)
  • Keep proportional distribution for uncontrolled panes (existing behavior)
  • Add tests for container resize behavior
  • Extend test setup to support triggering resize events

Root Cause

In SplitPane.tsx, handleContainerSizeChange unconditionally called distributeSizes() when the container resized, ignoring controlled size props. While there was a sync effect that attempted to restore controlled sizes, it:

  • Caused unnecessary re-renders
  • Could result in a visual "flash" of incorrect sizes
  • Created potential race conditions in fast resize scenarios

Test Plan

When using controlled mode with pixel sizes, panes were incorrectly
being scaled proportionally when the container/window resized. This
fix checks for controlled size props in handleContainerSizeChange and
uses calculateInitialSizes instead of distributeSizes to maintain
the fixed sizes from props.

- Add hasControlledSizes check in handleContainerSizeChange
- Use calculateInitialSizes for controlled panes on resize
- Keep proportional distribution for uncontrolled panes
- Add tests for container resize behavior
- Extend test setup to support triggering resize events

Fixes #868
@tomkp tomkp merged commit a840671 into master Jan 12, 2026
1 check passed
@tomkp tomkp deleted the fix/controlled-mode-resize-868 branch January 12, 2026 14:27
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.

Window resize issue with Controlled component

1 participant