Skip to content

Add configurable collapse behavior to AccordionPanel #775

@KH-Coder865

Description

@KH-Coder865

Problem

The current behavior of AccordionPanel (from Lumino, used in JupyterLab and Jupyter Notebook) redistributes space to the last open section when a section is collapsed. This causes the collapsed section’s title to move toward the bottom of the panel instead of collapsing in place.

This behavior is working as implemented, but it can be confusing in certain contexts. For example, in Jupyter Notebook 7.5.0rc1, the Running → Terminals panel uses an accordion layout. When a terminal entry is collapsed, the terminal section shifts to the bottom of the panel instead of closing under its own header, which feels unintuitive and appears broken to users.

At the same time, an alternative behavior (collapsing strictly in place) could also be confusing in other contexts, as it may make a section appear empty rather than collapsed. Because both behaviors have valid use cases, a single hard-coded strategy is limiting.

Related Notebook issue:
jupyter/notebook#7772
(dropdown menu for running terminals collapses unexpectedly)

Proposed Solution

Add a configuration option to AccordionPanel to control how space is redistributed when a section is collapsed.

For example, an option such as:

collapseMode: 'last-open' (current behavior, default)

collapseMode: 'in-place' (redistribute space to the nearest open neighbor)

This would preserve backward compatibility while allowing consumers (such as Jupyter Notebook or specific JupyterLab panels) to opt into a more context-appropriate behavior.

Once available, Jupyter Notebook’s Running panel could use the "in-place" behavior, while other uses (e.g. Extension Manager, sidebars) could continue using the existing default.

Additional context

  • The behavior originates in AccordionPanel._computeWidgetSize, where freed space is always reassigned to the last open widget.

  • Making the behavior configurable allows reuse of AccordionPanel across different UI patterns without forcing a one-size-fits-all interaction model.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions