Skip to content

Keep the right-panel toggle and table-of-contents rail mounted while hidden - #6490

Merged
ymichael merged 2 commits into
get-bb:mainfrom
JackALaing:fix/stable-right-panel-toggle
Oct 28, 2026
Merged

ymichael merged 2 commits into
get-bb:mainfrom
JackALaing:fix/stable-right-panel-toggle

Conversation

@JackALaing

Copy link
Copy Markdown
Contributor

Human comments

What was wrong

Toggling the right panel inserted or removed DOM nodes that do not need to change. On desktop the thread header's toggle button is unmounted while the panel is open and mounted again on close. On windows wider than about 1120 px, the table-of-contents rail is also unmounted or remounted mid-slide when the timeline crosses its 56 rem breakpoint. In Chromium, inserting or removing an element triggers :has() invalidation. With plugin or theme CSS that uses :has(), each of these restyled the whole page: once before the panel started moving, and on wide windows again during the slide. Details and measurements are in #6489.

What changed

  • ThreadDetailHeader: the right-panel toggle stays mounted whenever the header owns it. While the panel's own control owns closing on desktop, it is hidden with the hidden class and inert, so it is out of the accessibility tree and tab order, as it was when unmounted. Its label stays "Show right panel" while hidden, so selectors that match aria-label^="Show right panel" or "Hide right panel" still find exactly one visible control in each state. Compact behavior is unchanged.
  • ThreadTableOfContents: the rail stays mounted below the width breakpoint and is hidden with the hidden class and inert instead of being unmounted. The outline request is still gated on visibility.
  • Most of the ThreadTableOfContents.tsx diff is re-indentation from removing one conditional; git diff -w shows the four-line change.
  • No wire, CLI or documentation changes.

How you verified

  • New tests: ThreadDetailHeader.test.tsx "keeps one right-panel toggle mounted and hides it while the panel is open" and ThreadTableOfContents.test.tsx "keeps the rail mounted but hidden while the pane is too narrow". Both fail against main's components and pass with this change. The table-of-contents test's ResizeObserver mock gained a helper to deliver a new width.

  • pnpm exec turbo run typecheck lint --filter=@bb/app passes, with no new lint findings on changed lines. oxfmt --check passes on the changed files.

  • Related suites pass: the header and table-of-contents tests, ThreadSecondaryPanel.collapseControl, ThreadDetailSecondaryContent, SplitThreadArea, RootComposeRightPanelToggle, PluginPanelRightPanelHost and theme-preview-fixture-anatomy (212 tests).

  • Manual check in headless Chromium: production builds of main and of this branch, served against the same local server with about 35 plugin stylesheets and a custom theme. 4× CPU throttling; median of five repeated toggles, clicking the visible control.

    Window Input to first frame, main → this PR Longest frame during the slide, main → this PR
    1024 px 278 → 45 ms 283 → 300 ms (see limits)
    1440 px 268 → 42 ms 283 → 350 ms (see limits)
    1920 px 273 → 43 ms 283 → 67 ms
    390 px (compact) 220 → 294 ms 50 → 317 ms

    The compact path is unchanged by this PR. Earlier runs of both builds measured 196–218 ms there, so the 390 px difference is within run-to-run variation.

  • Accessibility tree, ⌘J, and the visible toggle's labels (Show / Hide) are identical to main in the open and closed states at 1440 px and 390 px.

Limits:

  • At 1024 and 1440 px the test thread has a long user message whose overflow state flips mid-slide. That inserts a show-more control in ExpandableTimelineRow and causes a separate long frame on main and on this branch alike. It is the same class of problem and could be a follow-up.
  • The first open after a page load and the compact shelf are not covered.
  • Not measured in the packaged Electron app, Safari or iOS.

Fixes #6489

AGENT GENERATED

Jack Laing added 2 commits October 28, 2026 17:59
Opening the panel unmounted the thread header's toggle and closing it
inserted the button again. Inserting or removing an element forces
:has() invalidation, so with plugin or theme CSS that uses :has() each
toggle restyled the whole page before the panel started moving.

Keep the button mounted and hide it with display:none and inert while
the panel's own control owns closing. Its label stays Show right panel
while hidden, so label-based selectors keep matching the visible
control.
The rail unmounted once the scroll overlay dropped below its width
breakpoint. Opening the right panel on a wide window crosses that
breakpoint mid-transition, so the rail was removed or inserted during
the animation and triggered a second full-page restyle.

Keep the rail mounted and hide it with display:none and inert below
the breakpoint.
@ymichael
ymichael marked this pull request as ready for review October 28, 2026 23:30
@ymichael
ymichael merged commit d9d130f into get-bb:main Oct 28, 2026
28 checks passed
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.

Toggling the right panel restyles the whole page when plugin or theme CSS uses :has()

2 participants