Repository navigation
Conversation
BoxLayout appended a new widget's node at the end of the panel and left a moved widget's node where it was, so Tab and screen readers reached the widgets in a different order than the panel shows them. JupyterLab's shell inserts its menu panel at index 3 of a top-to-bottom BoxLayout in the simple interface, and the panel ends up after the main area and the status bar in the DOM. attachWidget now inserts the node before the next widget's, and moveWidget moves it there too, sending the widget detach and attach messages around the move as PanelLayout does.
r0c0y
force-pushed
the
fix-boxlayout-dom-order
branch
from
November 25, 2026 14:21
60a494a to
89702ec
Compare
BoxLayout widgets in DOM order
r0c0y
marked this pull request as ready for review
November 25, 2026 14:28
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
References
AccordionPanel.insertWidgetdoes not move the section in the DOM, so the Tab order differs from the visual order #870, forBoxLayout: Keep accordion and split panel sections in DOM order #874 fixesAccordionLayoutandSplitLayout, and this one is independent of it (different files).BoxLayout, and in the simple interface it inserts the menu panel at index 3 (shell.ts, also at startup on L546).Code changes
BoxLayout.attachWidgetinserts the widget's node before the next widget's node instead of appending it.BoxLayout.moveWidgetnow moves the node to the same place. Around the move it sends the widgetbefore-detach,after-detach,before-attachandafter-attach, asPanelLayout.moveWidgetdoes, because the node leaves the DOM and comes back.Anchoring on the next widget's node, rather than on
children[index]asPanelLayoutdoes, leaves any other nodes in the panel's node where they are.User-facing changes
After
insertWidgetor a move, Tab and screen readers reach the widgets of aBoxPanelin the order of itswidgets. Fortop-to-bottomandleft-to-rightpanels, that is the order on screen. Panels drawn in reverse get the same DOM order, so aTabPanelwith its tabs at the bottom keeps its tab bar first, as today.In a JupyterLab dev build (Lumino 2.10.0) in the simple interface, the shell's children in DOM order, with each one's top on screen, are:
On
main, Tab from the document title skips the menu bar and reaches it only after the main area and the status bar. With this PR it goes to the menu bar next. The second line and the second picture come from the same page with this PR'sattachWidgetchange applied.Tests
boxlayout.spec.ts: an insert at an index, an insert into a panel whose node holds another node, moves to the start, the end and the middle (full DOM order each time), and the messages sent on a move. The four new tests fail onmain(988 passed, 4 failed; an insert at 1 then 0 gives[1, 3, 2, 0]) and pass here (992 passed) in Chromium and WebKit. Firefox does not start on my machine, so it is left to CI.eslint,prettier --checkandyarn apiare clean.I also ran a randomized check against both builds, in Chromium and WebKit: 16,000 inserts, moves, removals, hides and moves between panels. On
main, the DOM order differed from the layout order in 15,464 of the 32,000 checks; with this PR, in none, and each move of an attached widget sent exactly the four messages above.Backwards-incompatible changes
None in the API. Moving a widget of a
BoxPanelnow takes its node out of the DOM and puts it back, with the matching messages, asPaneldoes. Focus inside the moved widget is lost, and an iframe inside it reloads.AI usage
AccordionPanel.insertWidgetdoes not move the section in the DOM, so the Tab order differs from the visual order #870, wrote the fix and the tests, and ran the checks above.