Repository navigation
Studio: make the chat and sidebar menus open without freezing the page - #10262
Conversation
Review + GitHub Actions evidenceReviewed at The defect, on the merge baseA probe opens every reachable
In the same head run, five menus this PR does not touch ( What that looks likeSidebar seeded with 60 chats so the list overflows;
Findings fixed on this branchP2 — a menu that outlived its row ( Verified locally with Playwright in Chromium and WebKit (the desktop app's engine), on the merged branch: wheel over the sidebar closes the menu and the list stays where the user put it ( P2 — the dismiss guard outlived the menu ( The same probe, on two branches that differ only by the fix commit, measures it on Actions. It closes a menu, then clicks 30ms later and asks whether the click reaches a bubble-phase
Both routes, both branches. The control line matters: the identical click lands once the content has unmounted, so the check is measuring the window and not a dead button. The guard is now rendered only while the menu is open; arming still survives the unmount, because P3 — the Think effort menu had a modal twin. Test. Rewritten onto the TypeScript AST, the way Not changed
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Confirmed the sidebar and chat row menus in app-sidebar.tsx are still modal on main, so each open locks background scrolling and hides the rest of the app from assistive tech, and the shared component keeps the eight from drifting apart again. Will get this reviewed. |
|
Just noting this here since I mentioned it in chat: I reproduced the dropdown positioning issue from the AFTER screenshot with Playwright. If the sidebar is scrolled while the menu is open, the trigger moves off-screen but the menu stays open and gets clipped at the top. Pressing Escape then jumps the sidebar back to the trigger (scrollTop 480 to 0). Reproduced in Chrome, Edge, Chromium, and Firefox. |
# Conflicts: # studio/frontend/src/features/chat/shared-composer.tsx
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Rechecked the latest head fbb5884 with the same Playwright repro and this is fixed now 👍 After a 480px sidebar scroll, the menu closes, scrollTop stays at 480, and Escape no longer snaps it back to 0. Confirmed in WSL Chromium/Firefox and native Windows Chrome/Edge. Thanks! |
The AST tests pin which menus use NonModalDropdownMenu. What the wrapper then does is only answerable in a browser, and it is where this has gone wrong before: a dismissal deleting a chat message (unslothai#9243), a lost trigger focus (unslothai#9772), a guard that outlived the exit animation, and a menu left anchored to a row that had scrolled away. smoke-nonmodal-menus.html mounts the real component on a 60 row overflowing list, with a submenu, a menu whose own viewport scrolls, an unrelated scroller, and one still-modal menu as a control. The control is the shape every converted menu had before, so a case that behaves the same on both is Radix rather than this wrapper, and the lock it still writes to <body> is what proves the probe can see a lock at all. 34 checks, passing on chromium, firefox and webkit. Frontend CI runs the chromium leg next to the existing dismiss-guard probe; PW_ENGINE picks the other two.
Whether the reopening click lands while Radix still has the closing content mounted is a race, and the converted menu and the unconverted control each win it about as often on Windows Firefox, which made the comparison red for no defect. Assert the part that is not a race: neither may end up with two menus open.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fd3bc5a622
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return () => document.removeEventListener("scroll", onScroll, { capture: true }); | ||
| }, [open]); | ||
| return ( | ||
| <DropdownMenu modal={false} open={open} onOpenChange={setOpen}> |
There was a problem hiding this comment.
Clear the scroll-close marker when reopening
If a scroll closes the menu and the user reopens it during the 100 ms exit animation, the content never unmounts, so onCloseAutoFocus does not run and closedByScroll.current remains true. Dismissing that reopened menu by clicking an input then incorrectly follows the scroll-close path and focuses the trigger, stealing focus and the caret from the input. Clear the marker when onOpenChange transitions back to open rather than relying solely on the eventual close-autofocus callback.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Tried to reproduce this and could not: the precondition is unreachable. Reopening a menu while its closing content is still mounted does not work on any engine, because the press lands on a DismissableLayer that is still there and closes it again. Swept the delay between the scroll-close and the reopening click, reading [data-slot=dropdown-menu-content] at the moment of the click:
| delay | content at click | reopened |
|---|---|---|
| 0 to 80ms | present, data-state=closed |
no, on all three engines |
| 100ms | present on chromium and firefox, gone by the time the click lands | yes on chromium and firefox, no on webkit |
| 150ms and up | gone | yes on all three |
So the reopen only lands once the content has unmounted, and unmount is exactly when onCloseAutoFocus runs and clears closedByScroll. There is no window where the flag survives into a later close. The wrapper also exposes no root level open, so a caller cannot reopen it by another route.
The downstream symptom is covered either way: a scroll-close does not change how the next Escape restores focus in tests/studio/playwright_nonmodal_menus.py passes on chromium, firefox and webkit.
Two things the driver needed and did not have. tests/studio/playwright_nonmodal_menus.py was missing from the workflow's pull_request paths, where every other driver this job invokes is listed, so a PR touching only the harness would never run it. And its report was not in the failure upload, which test_every_smoke_report_is_covered_by_the_failure_upload rejects by design, so the required workflow-trigger-lint job was red.
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Converged. Codex approved Two of its three items on my commits were right and are fixed in The one red check on this PR is not this PR. Cross-OS re-run on the current head is green again, all nine cells, after one unrelated flake on macOS ( |
tests/studio/test_click_forced.py rejects a forced click that does not scroll first, and it is right to: force turns the scroll off and Playwright will not click a point it cannot reach. The sanctioned helper scrolls into view, which is the one thing this case must not do, since it is about a trigger the scroller clips. A real pointer press on the intersection of the trigger and the scroller keeps the case and needs no force at all. Still 34/34 on chromium, firefox and webkit.
…closed The content is held mounted for its exit animation, so a scroll close can be followed by a click into an input before onCloseAutoFocus runs. Radix's own restore checks for that interaction, but the scroll-close path calls preventDefault, which skips the check, so the trigger pulled the caret straight back out of the input. Measured on chromium, firefox and webkit: with the menu scroll-closed and the input clicked 0 to 90ms later, focus ended on the trigger every time, against the input on an ordinary close. Make the same check before taking focus. The case the path exists for is unchanged: with nothing else claiming focus, a scroll close still lands on the trigger and still keeps the scroll, 600px in all three engines. The regression case fails without this and passes with it.
|
@codex review |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |

Opening the sidebar menus, the chat row menu or the project menu locks the whole page while the menu is open. The background cannot be scrolled, the scrollbar disappears and comes back so the layout jumps, and screen readers are told the rest of the app is hidden. The cost grows with the length of the chat, so on a long thread each open is a visible pause. Two menus in the app already avoid this.
This moves eight menus onto the same approach, through one shared component so they cannot drift apart again. The component holds the guard that stops the click which closes a menu from also hitting whatever is under it.
Tested in a browser on both builds. Before, opening any of them locks page scrolling and hides about ten elements from screen readers. After, the page is untouched and every menu still opens.