Skip to content

Feature Added: Collapse Configs('In-place' config added) for AccordionPanel#776

Open
KH-Coder865 wants to merge 29 commits intojupyterlab:mainfrom
KH-Coder865:accordion-collapse-config
Open

Feature Added: Collapse Configs('In-place' config added) for AccordionPanel#776
KH-Coder865 wants to merge 29 commits intojupyterlab:mainfrom
KH-Coder865:accordion-collapse-config

Conversation

@KH-Coder865
Copy link
Copy Markdown

@KH-Coder865 KH-Coder865 commented Jan 11, 2026

What this PR does:

This PR adds a new collapseMode option to AccordionPanel that allows configuring how sections collapse:

  • 'last-open' (default): current behavior, the last open widget expands to the bottom
  • 'in-place': collapses the widget in its current position, redistributing its size to the nearest open neighbor

Changes:

  • Added _collapseMode property to AccordionPanel with optional getter/setter
  • Updated _computeWidgetSize to handle both 'last-open' and 'in-place' collapse modes
  • Updated JSDoc for IOptions.collapseMode with example usage

Example usage:

const panel = new AccordionPanel({
  collapseMode: 'in-place',
  orientation: 'vertical'
});

panel.addWidget(myWidget1);
panel.addWidget(myWidget2);

Additional context:

Fixes:

Labels:

  • enhancement

@krassowski krassowski added the enhancement New feature or request label Jan 13, 2026
@krassowski
Copy link
Copy Markdown
Member

Maybe it would be worth adding an example panel with this option enabled in https://github.com/jupyterlab/lumino/tree/main/examples/example-accordionpanel ?

@KH-Coder865
Copy link
Copy Markdown
Author

Refactor accordion implementation to support default and in-place collapse modes.
@KH-Coder865
Copy link
Copy Markdown
Author

Hello @krassowski,
Thanks for the suggestion.

I’ve added an example panel to examples/example-accordionpanel that demonstrates the new collapseMode: 'in-place' option side by side with the default behavior, so the difference is easy to see in practice.

Hope these changes are in accordance with what you had in mind.

Thanks for the review!

Comment thread examples/example-accordionpanel/src/index.ts
@krassowski
Copy link
Copy Markdown
Member

krassowski commented Jan 13, 2026

Great, now we have a preview on https://lumino--776.org.readthedocs.build/en/776/examples/accordionpanel/index.html

I don't see a difference in behaviour in the preview though? Am I missing something?

It looks like it would be good to add orange and purple to:

.red > div {
background: #e74c3c;
}
.yellow > div {
background: #f1c40f;
}
.green > div {
background: #27ae60;
}
.blue > div {
background: #3498db;
}

@krassowski
Copy link
Copy Markdown
Member

Hmm I see that if collapsing the middle panel there is a difference but I am not sure if this works as intended in general.

image

Refactor accordion panel to conditionally add spacer widget based on collapse mode. Update titles getter to filter out spacer when present.
@KH-Coder865
Copy link
Copy Markdown
Author

Hello @krassowski .
Have successfully done all the required changes and also verified using the preview - the proper working of in-place configuration.
Kindly confirm.

@KH-Coder865
Copy link
Copy Markdown
Author

Ran Prettier on edited files.

@KH-Coder865
Copy link
Copy Markdown
Author

Hello @krassowski,
I’ve completed all the requested changes for this issue.
If everything looks good from your side, we can proceed with the related notebook issue: jupyter/notebook#7772

Thanks for taking another look — I appreciate you re-running the workflows.

@KH-Coder865
Copy link
Copy Markdown
Author

Hi @krassowski , it would be great if you could take a look at this. I think the in-place configuration has been successfully added and working as intended.
Thanks

@KH-Coder865 KH-Coder865 marked this pull request as draft January 20, 2026 09:47
@KH-Coder865 KH-Coder865 marked this pull request as ready for review January 20, 2026 09:47
@KH-Coder865
Copy link
Copy Markdown
Author

Hi @krassowski .
Waiting for your feedback.
So that we can proceed with related issues.

@KH-Coder865
Copy link
Copy Markdown
Author

Hello @krassowski , if everything looks good then please let me know so that we can start working on related issues.

Waiting for the review.

@KH-Coder865
Copy link
Copy Markdown
Author

Hello @krassowski
Waiting for the review.

@krassowski
Copy link
Copy Markdown
Member

It looks like it does not cover 100% of the height of the screen, this looks unintended to me?

image

@KH-Coder865
Copy link
Copy Markdown
Author

No, its done intentionally.
Actually the default behavior of the Split Panel layout is to cover the the full height(by redistributing the space to the other blocks), and that was the main cause of the "dropping down" behavior of the last dropdown.

So, I didn't changed its default behavior (to keep its current applications intact everywhere, like in notebook), instead, in the new configuration for the Accordion Panel, I changed the redistribution logic, by adding a fake container at the very end, which isn't visible but it plays a role in space redistribution.
Earlier, the last container did seem to fall down on closing, because its space was redistributed to its nearest previous open container, but, in the new configuration, when the last(according to the user) container closes, its space is redistributed to its nearest next container(which is not visible to the user), thus giving the effect that it closed "in-place".
Means, the default property of the Split Panel of covering the full height is still intact.

Makes sense?

@krassowski
Copy link
Copy Markdown
Member

Well, so it does solve a problem, but introduces another issue - the space is not fully utilized. I does not feel like the right solution to me but I will let others chime in.

@KH-Coder865
Copy link
Copy Markdown
Author

Yes, sure!
Let me know, if any changes required.

@KH-Coder865
Copy link
Copy Markdown
Author

But, I personally think, that if we keep the constraint of occupying the full height, then we would have to redistribute the spaces among containers, and this will indeed result in a dropping down action of the last dropdown of Accordion Panel.

That's why this new configuration was needed, to tackle that redistribution problem.

Further, I am open to corrections and making changes.

@KH-Coder865
Copy link
Copy Markdown
Author

KH-Coder865 commented Feb 14, 2026

I request @krassowski @andrii-i @fcollonval @jtpio to please put forward their thoughts or reviews on this.

@KH-Coder865
Copy link
Copy Markdown
Author

Hello @krassowski 👋

I believe that this PR is now ready for merging. As it just adds a functionality to the existing stack (which can be used if required) and doesn't modify the existing behaviour of this accordion panel in other places like notebook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants