Skip to content

Comments

[pull] main from bvaughn:main#93

Merged
pull[bot] merged 4 commits intocode:mainfrom
bvaughn:main
Feb 3, 2026
Merged

[pull] main from bvaughn:main#93
pull[bot] merged 4 commits intocode:mainfrom
bvaughn:main

Conversation

@pull
Copy link

@pull pull bot commented Feb 3, 2026

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

bvaughn and others added 4 commits February 2, 2026 16:46
)

This should work around an undesirable edge case with "click" events
that was reported in #627, while still maintaining the performance
optimization added in #638.

I have published this change as alpha version
`react-resizable-panels@4.5.9-alpha.0`

@michaelboyles Please verify this fixes the "click" issue you reported

@evanfrawley Sorry to ask, but can you confirm this change doesn't
negatively impact the issue you reported in #637?
I have a three panel layout and am attempting to persist the absolute
width of some panels when conditionally rendering others, i.e. switching
between a 2 and 3 panel layout. I can do this via the `setLayout`
imperative API method, roughly something like this:

```ts
const lastLayout = useRef<Layout>(ref.current?.getLayout() ?? {})

// This is passed as the Group component's onLayoutChanged prop.
const handleLayoutChanged = (layout: Layout) => {
    const next = {...layout}
    const prev = lastLayout.current
    const nextLength = Object.keys(next).length
    const prevLength = Object.keys(prev).length

    if (prevLength !== nextLength) {
      // Persist these
      if ('navigation' in next && 'navigation' in prev) {
        next.navigation = prev.navigation
      }
      if ('sidebar' in next && 'sidebar' in prev) {
        next.sidebar = prev.sidebar
      }
      // Apply remaining space to content
      if ('content' in next && 'content' in prev) {
        next.content = 100 - (next.navigation ?? 0) - (next.sidebar ?? 0)
      }
      ref.current?.setLayout(next)
    }

    lastLayout.current = next
    onLayoutChanged(next)
  }
```

However, currently `setLayout` doesn't seem to persist layouts to the
`inMemoryLayouts` cache. As a result I am finding that when panels
subsequently change (in my case on route change in my application), the
layout is I assume read from the stale cache, and the panels snap back
to the layout received by `handleLayoutChanged` prior to when I called
`setLayout`.

This fix just persists those layouts to the cache, which after testing
this locally, seems to work.

Let me know if you'd like more detail or a repro.
@pull pull bot locked and limited conversation to collaborators Feb 3, 2026
@pull pull bot added the ⤵️ pull label Feb 3, 2026
@pull pull bot merged commit 4a5e519 into code:main Feb 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants