8000 Keep accordion and split panel sections in DOM order by r0c0y · Pull Request #874 · jupyterlab/lumino · GitHub
[go: up one dir, main page]

Skip to content

Keep accordion and split panel sections in DOM order - #874

Open
r0c0y wants to merge 5 commits into
jupyterlab:mainfrom
r0c0y:fix-accordion-dom-order
Open

r0c0y wants to merge 5 commits into
jupyterlab:mainfrom
r0c0y:fix-accordion-dom-order

Conversation

@r0c0y
@r0c0y r0c0y commented Nov 21, 2026 •
Copy link
Copy Markdown
Contributor

References

Code changes

  • SplitLayout.attachWidget inserts the widget and handle nodes after the previous section's handle (or first, for index 0) instead of appending them.
  • SplitLayout.moveWidget now moves the widget and handle nodes to the same place.
  • AccordionLayout.attachWidget and moveWidget put the title right before its widget after the split layout has placed it. The title is still in the DOM before the widget's after-attach, as before.
  • A private helper SplitLayout._sectionReference(index) finds the node a section goes before. The API report does not change.

User-facing changes

Tab and screen readers now reach accordion and split panel sections in the order the panel shows them. With the snippet from #870:

main With this change
after insertWidget(2, c) shown A B C D, DOM A B D C shown A B C D, DOM A B C D
after insertWidget(0, panel.widgets[3]) shown D A B C, DOM A B D C shown D A B C, DOM D A B C

Tests: one for AccordionPanel with the snippet from the issue, and for AccordionLayout and SplitLayout, the full order of titles, widgets and handles after inserts at the start and in the middle, after moves to the start and the end, and the messages sent on a move. The six five new tests fail on main (979 980 passed, 6 5 failed) and pass here (985 passed) in Chromium; eslint, prettier --check and yarn api are clean.

Added by a maintainer

The message test checks that a move sends no detach messages. main sends none either, so this test passes on main.

Backwards-incompatible changes

None in the API. Moving a section of a SplitPanel or AccordionPanel now detaches and re-attaches its widget in the DOM, with the matching messages, moves its nodes in the DOM, which it did not before. Code that moved these nodes by hand to work around this, like JupyterLab's, still ends with the same order.

Added by a maintainer

The moved widget stays attached and gets no detach or attach messages. JupyterLab's ReactWidget unmounts its React tree on before-detach, so this keeps the state of a moved sidebar section, such as an expanded variable in the debugger. Moving the nodes drops the focus and the scroll position inside the moved section and reloads its iframes.

AI usage

  • YES: Some or all of the content of this PR was generated by AI.
  • YES: The human author has carefully reviewed this PR and run this code.
  • AI tools and models used: Claude Code (Opus 5.5); Opus 5.5 (max effort) for the maintainer changes

AccordionLayout and SplitLayout appended a new section's nodes at the
end of the panel and left a moved section's nodes where they were, so
Tab and screen readers reached the sections in a different order than
the panel shows them.

SplitLayout now inserts and moves a section's widget and handle after
the previous section's handle, sending the widget detach and attach
messages around a move as PanelLayout does, and AccordionLayout puts
the title before its widget.

Fixes jupyterlab#870
@krassowski krassowski added the bug Something isn't working label Nov 25, 2026
@krassowski krassowski left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There is a small simplification that we can do but otherwise this looks good, thanks!

Comment thread packages/widgets/src/splitlayout.ts Resolved
@krassowski krassowski left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

This branch has not been deployed

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AccordionPanel.insertWidget does not move the section in the DOM, so the Tab order differs from the visual order

2 participants

0