Skip to content

How to prevent panel from expanding back after hitting minSize when container grows? #676

Description

@callmeYe

Summary

I'm not reporting a bug — I'm looking for guidance on how to achieve
a specific resize behavior when the container size changes dynamically.

Use Case

I have a chat-like layout with two panels stacked vertically:

  • Panel A (input box): has minSize and maxSize constraints,
    and can be manually resized by the user via a resize handle
  • Panel B (conversation area): no size constraints
<PanelGroup direction="vertical">
  <Panel>
    Panel B (conversation area)
  </Panel>
  <PanelResizeHandle />
  <Panel minSize={100} maxSize={200}>
    Panel A (input box)
  </Panel>
</PanelGroup>

Current Behavior

When the container shrinks:

  1. Panel A and Panel B shrink proportionally ✅
  2. Once Panel A hits minSize, only Panel B continues to shrink ✅

When the container grows back:
3. Panel A and Panel B both grow proportionally

Expected Behavior

When the container grows back after Panel A has hit minSize:
3. Panel A should stay at minSize and remain unchanged
4. Only Panel B should grow to fill the extra space ✅

In other words, once Panel A has been "pinned" to its minSize due to
container shrinking, it should not automatically expand when the
container grows back — only Panel B should absorb the new space.

Real-World Scenario

This happens in practice when using browser DevTools:

  1. Open DevTools docked to the bottom → container height shrinks
  2. Panel A (input box) hits minSize and stops shrinking
  3. Panel B (conversation area) continues to shrink ✅
  4. Close DevTools → container height grows back
  5. Both panels grow proportionally, causing Panel A (input box)
    to become disproportionately large again ❌

The user had previously manually resized Panel A to a comfortable
height. After the DevTools open/close cycle, Panel A is no longer
at the user's preferred size, which is a poor UX.

What I've Tried / What I'm Looking For

Is there a recommended way to achieve this behavior?

For example:

  • Listening to a "panel hit minSize" event and locking Panel A's size?
  • Using onLayout to detect and manually correct the layout after
    the container grows?
  • Setting imperative panel ref to programmatically fix Panel A's
    size once it hits minSize?

Any guidance or workaround would be greatly appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions