Skip to content

fix: edge case collapse last panel#703

Merged
bvaughn merged 8 commits intobvaughn:support-focus-visible-stylefrom
hugs7:bugfix/collapse-last-panel
May 2, 2026
Merged

fix: edge case collapse last panel#703
bvaughn merged 8 commits intobvaughn:support-focus-visible-stylefrom
hugs7:bugfix/collapse-last-panel

Conversation

@hugs7
Copy link
Copy Markdown

@hugs7 hugs7 commented Apr 6, 2026

When collapsing the a panel within a group where all other (previous) panels are already collapsed, there's currently a bug where the delta calculation cascades to cause the first panel to expand. This is undesired since the first panel should remain collapsed given we are not touching it.

This fix handles the edge case by computing the remaining space percentage for the last panel to take up, thus leaving previous panels undisturbed.

By "previous" panels here I mean panels above (vertical mode) or to the left (horizontal) mode.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 6, 2026

@hugs7 is attempting to deploy a commit to the Brian Vaughn's projects Team on Vercel.

A member of the Team first needs to authorize it.

@hugs7
Copy link
Copy Markdown
Author

hugs7 commented Apr 6, 2026

Hi @bvaughn , could you kindly have a look at my PR?

const allPreviousCollapsed =
isLastPanel &&
nextSize < prevSize &&
(isFirstPanel ||
Copy link
Copy Markdown
Author

@hugs7 hugs7 Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also noticed this assertion error can happen when collapsing the one and only panel in a group, since the delta value otherwise goes to 100 causing it to index at -1 here at adjustLayoutByDelta on line 142

Image

Copy link
Copy Markdown
Author

@hugs7 hugs7 Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've addressed this in this PR via the following logic: If there's only one panel in the group, we can still collapse it but leave it's flex-grow value at 100%

@hugs7
Copy link
Copy Markdown
Author

hugs7 commented Apr 6, 2026

Unit tests

image

@bvaughn
Copy link
Copy Markdown
Owner

bvaughn commented Apr 6, 2026 via email

@hugs7
Copy link
Copy Markdown
Author

hugs7 commented Apr 6, 2026

No rush. Please take your time to review

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 10, 2026

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

Project Deployment Actions Updated (UTC)
react-resizable-panels Ready Ready Preview May 2, 2026 7:45pm

@bvaughn
Copy link
Copy Markdown
Owner

bvaughn commented Apr 10, 2026

Have not reviewed the code yet. TBH I'm still probably too exhausted to do this, BUT– I would like to see at least two new unit tests to be included w/ this sort of PR (for the edge cases you mention)

If you're willing to add them, I'd appreciate it!

@hugs7
Copy link
Copy Markdown
Author

hugs7 commented Apr 11, 2026

Sure can do - please allow me some time

@hugs7 hugs7 force-pushed the bugfix/collapse-last-panel branch from 89515f5 to 115460f Compare April 26, 2026 05:22
@hugs7
Copy link
Copy Markdown
Author

hugs7 commented Apr 26, 2026

HI @bvaughn , apologies for delay - I've added some unit tests

@bvaughn bvaughn force-pushed the bugfix/collapse-last-panel branch from 1e36027 to ce39dc9 Compare May 2, 2026 19:44
@bvaughn bvaughn changed the base branch from main to support-focus-visible-style May 2, 2026 19:48
@bvaughn
Copy link
Copy Markdown
Owner

bvaughn commented May 2, 2026

Thank you!

@bvaughn bvaughn merged commit 8974566 into bvaughn:support-focus-visible-style May 2, 2026
7 checks passed
bvaughn added a commit that referenced this pull request May 2, 2026
- [712](#712): `Separator` supports `:focus-visible` pseudo-class
- [703](#703): Fix: edge case scenarios when collapsing the last panel
- [711](#711): Improve legacy browser support wrt global stylesheets
@bvaughn
Copy link
Copy Markdown
Owner

bvaughn commented May 2, 2026

This change has been release as part of 4.11.0.

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.

2 participants