Skip to content

[Bug]: Resizable.Panel doesn't respect changes to collapsedSize #94

@olivercoad

Description

@olivercoad

Bug description

If you change the value of a panel's collapsedSize property, it doesn't do change its behaviour. It always uses the initial value.
Given that usePanelContext().collapsedSize is an accessor, it implies that the intention is that the value can change, which is what makes me believe this is a bug rather than intended behavior. Indeed, the accessor does pick up the new prop value, and collapsed changes to false when the collapsedSize is different to the original (see repro).

Reproduction Link

https://stackblitz.com/edit/corvu-69tnjqxd?file=src%2FApp.tsx

Reproduction Steps

  1. Click on "Toggle Collapsed Size"
  2. Drag the handle left to collapse the left panel
  3. Observe that it collapses to size 0.2 (the initial collapsedSize) instead of 0.3 and that is says "Collapsed: no"

Expected behavior

If not currently collapsed: changing collapsedSize should do nothing, until the panel is collapsed, at which point it should use the new value.
If already collapsed: changing collapsedSize should immediately change the size of the panel.

Additional context

This issue is specifically about collapsedSize because my use-case requires it,
but I suspect there are probably similar issues for other properties that the root doesn't get notified of changes to.

const instance = untrack(() => {
return _context.registerPanel({
id: localProps.panelId,
element,
initialSize: localProps.initialSize,
minSize: localProps.minSize,
maxSize: localProps.maxSize,
collapsible: localProps.collapsible,
collapsedSize: localProps.collapsedSize,
collapseThreshold: localProps.collapseThreshold,
onResize: localProps.onResize,
})
})

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions