fix(site/src): keep fixed-height menus within the viewport (#32746)
The shared menu content (`menuClasses.ts`) caps height at `--radix-popper-available-height` and scrolls. Menus that passed their own fixed `max-h-*` replaced that cap, because `cn` (tailwind-merge) lets the caller's class win. When less than the fixed height fit next to the trigger, for example at 200% zoom, those menus ran past the viewport. - **DEQ-640:** the fixed caps become `max-h-[min(<fixed>,var(--radix-popper-available-height))]`. The `overflow-*` overrides are dropped because the shared class already scrolls. `PRMenuLinks`' `overflow-auto` also re-enabled horizontal scrolling. - **DEQ-641:** the proxy list's inner `max-h-[calc(100vh-22rem)] overflow-y-auto` wrapper is removed. It collapsed to about 100px on short viewports and nested a second scroll region inside the already scrolling menu. The menu is now the only scroll region. Closes DEQ-640 Closes DEQ-641 | Ticket | UI surface | Screenshots | |---|---|---| | DEQ-640 | Agent log tabs overflow menu, agent log download menu, Agents PR links menu (top bar and sidebar submenu), Agents "Move to project" submenu | [DEQ-640 screenshots](https://linear.app/codercom/issue/DEQ-640#comment-94f27284) | | DEQ-641 | Navbar Proxy menu | [DEQ-641 screenshots](https://linear.app/codercom/issue/DEQ-641#comment-8b17a825) | Measured in Storybook: - `ChatTopBar/WithManyPRs` at 1280x180: on `main` the menu ends at 235px, 55px past the viewport. On this branch it ends at 180px. - `ProxyMenu/ManyProxiesOpened` at 1200x450: on `main` there is a 98px nested scroller. On this branch there is none and the menu scrolls to the viewport edge. - Arrow-key navigation keeps the focused proxy in view. <details> <summary>Decision log and notes</summary> - `MoveToProjectMenuItems.tsx` (`max-h-80 overflow-y-auto` on `SubContent`) has the same root cause and turned up while searching for other callers, so I included it. - No new tests. This is layout only and jsdom can't measure it. Pixel covers `ProxyMenu/ManyProxiesOpened` and `ChatTopBar/WithManyPRs`. Expect a baseline change on `ManyProxiesOpened`: the header and footer items now scroll with the list, and the `scrollbar-thin` styling on the inner list is gone. - axe flags `scrollable-region-focusable` on the scrolling Radix menu container. That happens on `main` too for any menu that scrolls (for example `WithManyPRs`), because Radix menu items use roving `tabindex=-1`. It isn't introduced here. On `main`, the ProxyMenu flag was on the inner wrapper this PR removes. Keyboard access works: arrow keys move focus and scroll the menu. - Reworded the `PRMenuLinks` doc comment to "fits up to five rows", because a short viewport now scrolls sooner. - Self-review: frontend-review, frontend-deep-review, and frontend-accessibility found no blocking or should-fix issues. </details> 🤖 Generated by Coder Agents on behalf of @bartekgatzcoder.
This commit is contained in:
1 parent
4f70a77a40
commit
893d239a04
5 files changed
+46
-48
No files matched your search
@@ -138,53 +138,51 @@ export const ProxyMenu: React.FC<ProxyMenuProps> = ({ proxyContextValue }) => {
|
||||
)}
|
||||
|
||||
{proxyContextValue.proxies && (
|
||||
<div className="max-h-[calc(100vh-22rem)] -mr-2 pr-2 overflow-y-auto scrollbar-thin">
|
||||
<DropdownMenuRadioGroup value={selectedProxy?.id}>
|
||||
{sortProxiesByLatency(proxyContextValue.proxies, latencies).map(
|
||||
(proxy) => (
|
||||
<DropdownMenuRadioItem
|
||||
value={proxy.id}
|
||||
key={proxy.id}
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
if (!proxy.healthy) {
|
||||
toast.error(
|
||||
`Failed to select proxy "${proxy.display_name}".`,
|
||||
{
|
||||
description:
|
||||
"Please select a healthy workspace proxy.",
|
||||
},
|
||||
);
|
||||
closeMenu();
|
||||
return;
|
||||
}
|
||||
|
||||
proxyContextValue.setProxy(proxy);
|
||||
<DropdownMenuRadioGroup value={selectedProxy?.id}>
|
||||
{sortProxiesByLatency(proxyContextValue.proxies, latencies).map(
|
||||
(proxy) => (
|
||||
<DropdownMenuRadioItem
|
||||
value={proxy.id}
|
||||
key={proxy.id}
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
if (!proxy.healthy) {
|
||||
toast.error(
|
||||
`Failed to select proxy "${proxy.display_name}".`,
|
||||
{
|
||||
description:
|
||||
"Please select a healthy workspace proxy.",
|
||||
},
|
||||
);
|
||||
closeMenu();
|
||||
}}
|
||||
>
|
||||
<div className="flex gap-3 items-center w-full">
|
||||
<div className="leading-none size-4">
|
||||
<ExternalImage
|
||||
src={proxy.icon_url}
|
||||
alt=""
|
||||
className="object-contain size-full"
|
||||
/>
|
||||
</div>
|
||||
return;
|
||||
}
|
||||
|
||||
{proxy.display_name}
|
||||
|
||||
<Latency
|
||||
className="ml-auto"
|
||||
latency={latencies?.[proxy.id]?.latencyMS}
|
||||
isLoading={proxyLatencyLoading(proxy)}
|
||||
proxyContextValue.setProxy(proxy);
|
||||
closeMenu();
|
||||
}}
|
||||
>
|
||||
<div className="flex gap-3 items-center w-full">
|
||||
<div className="leading-none size-4">
|
||||
<ExternalImage
|
||||
src={proxy.icon_url}
|
||||
alt=""
|
||||
className="object-contain size-full"
|
||||
/>
|
||||
</div>
|
||||
</DropdownMenuRadioItem>
|
||||
),
|
||||
)}
|
||||
</DropdownMenuRadioGroup>
|
||||
</div>
|
||||
|
||||
{proxy.display_name}
|
||||
|
||||
<Latency
|
||||
className="ml-auto"
|
||||
latency={latencies?.[proxy.id]?.latencyMS}
|
||||
isLoading={proxyLatencyLoading(proxy)}
|
||||
/>
|
||||
</div>
|
||||
</DropdownMenuRadioItem>
|
||||
),
|
||||
)}
|
||||
</DropdownMenuRadioGroup>
|
||||
)}
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
@@ -633,7 +633,7 @@ export const AgentRow: React.FC<AgentRowProps> = ({
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent
|
||||
align="end"
|
||||
className="max-h-56 overflow-y-auto"
|
||||
className="max-h-[min(14rem,var(--radix-popper-available-height))]"
|
||||
>
|
||||
<DropdownMenuRadioGroup
|
||||
value={selectedLogTab}
|
||||
|
||||
@@ -71,7 +71,7 @@ export const DownloadSelectedAgentLogsButton: React.FC<
|
||||
<DropdownMenuContent
|
||||
side="bottom"
|
||||
align="end"
|
||||
className="max-h-56 overflow-y-auto"
|
||||
className="max-h-[min(14rem,var(--radix-popper-available-height))]"
|
||||
>
|
||||
<DropdownMenuItem
|
||||
disabled={!hasAllLogs}
|
||||
|
||||
@@ -97,7 +97,7 @@ export const MoveToProjectMenuItems: React.FC<MoveToProjectMenuItemsProps> = ({
|
||||
<FolderInputIcon />
|
||||
Move to project
|
||||
</SubTrigger>
|
||||
<SubContent className="max-h-80 max-w-72 overflow-y-auto">
|
||||
<SubContent className="max-h-[min(20rem,var(--radix-popper-available-height))] max-w-72">
|
||||
{projectsQuery.isPending && <Item disabled>Loading projects…</Item>}
|
||||
{projectsQuery.isError && (
|
||||
<Item disabled>
|
||||
|
||||
@@ -6,9 +6,9 @@ import { originRepoLabel } from "../utils/originRepoLabel";
|
||||
import { prNumber } from "../utils/pullRequest";
|
||||
import { getPRIconConfig } from "./ChatsSidebar/tree/statusConfig";
|
||||
|
||||
/** Menu content for PR links. The height fits five rows before it scrolls. */
|
||||
/** Menu content for PR links. The height fits up to five rows before it scrolls. */
|
||||
export const prMenuContentClassName =
|
||||
"max-h-50 w-72 overflow-auto **:[[role=menuitem]]:text-[13px]";
|
||||
"max-h-[min(12.5rem,var(--radix-popper-available-height))] w-72 **:[[role=menuitem]]:text-[13px]";
|
||||
|
||||
type PRMenuLinksProps = {
|
||||
readonly prStatuses: readonly ChatDiffStatus[];
|
||||
|
||||
Reference in new issue
Block a user