From b5f5ab36a1f4b626da9de40adf7e40257967997c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Sat, 14 Nov 2026 21:20:03 -0500 Subject: [PATCH] fix(studio): menu row highlight follows the menu's corner (#7791) * fix(studio): menu row highlight follows the menu's corner * fix(studio): keep the menu row's comment share flat * fix(studio): export the menu row class so hosts reuse it --- packages/studio/src/components/ui/Menu.test.tsx | 8 +++++--- packages/studio/src/components/ui/Menu.tsx | 13 ++++++++----- packages/studio/src/components/ui/index.ts | 1 + packages/studio/src/ui.ts | 1 + 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/packages/studio/src/components/ui/Menu.test.tsx b/packages/studio/src/components/ui/Menu.test.tsx index f6b2caba2b..220a436fe1 100644 --- a/packages/studio/src/components/ui/Menu.test.tsx +++ b/packages/studio/src/components/ui/Menu.test.tsx @@ -443,12 +443,14 @@ describe("open motion", () => { ); }); - it("rounds a row's highlight more than the panel that holds it", async () => { + it("rounds a row's highlight to the panel's corner less the panel's inset", async () => { await openActionMenu(); const rowRadius = [...items()[0]!.classList].find((c) => c.startsWith("rounded-"))!; - expect([...popup()!.classList]).toContain("rounded-lg"); - expect(compileStudioCss([rowRadius])).toMatch(/calc\(var\(--radius-lg\) \+ 6px\)/); + expect([...popup()!.classList]).toEqual(expect.arrayContaining(["rounded-lg", "p-1"])); + expect(compileStudioCss([rowRadius])).toMatch( + /border-radius: calc\(var\(--radius-lg\) - 4px\)/, + ); }); }); diff --git a/packages/studio/src/components/ui/Menu.tsx b/packages/studio/src/components/ui/Menu.tsx index 5e0046d017..04792479d5 100644 --- a/packages/studio/src/components/ui/Menu.tsx +++ b/packages/studio/src/components/ui/Menu.tsx @@ -71,8 +71,8 @@ export const POPUP_LAYER = "z-200"; const menuPopup = cn(popupSurface, "min-w-36 p-1 shadow-menu"); /** One row. `data-highlighted` is set by keyboard and pointer alike, so the seen row is the Enter row. */ -const itemBase = cn( - "flex cursor-default select-none items-center justify-between gap-6 rounded-[calc(var(--radius-lg)+6px)] px-2 py-1.5", +export const menuItemBase = cn( + "flex cursor-default select-none items-center justify-between gap-6 rounded-[calc(var(--radius-lg)-4px)] px-2 py-1.5", "text-step-11 whitespace-nowrap text-text-1", "outline-hidden transition-colors ease-out-quint duration-hover", "data-[highlighted]:bg-hover data-[highlighted]:text-text-0", @@ -210,7 +210,10 @@ interface MenuItemProps extends StyledProps { /** One action. `disabled` items are skipped by the arrow keys, not just dimmed. */ export function MenuItem({ shortcut, tone, className, children, ...props }: MenuItemProps) { return ( - + {children} {shortcut ? {shortcut} : null} @@ -229,7 +232,7 @@ interface MenuRadioItemProps extends StyledProps { /** One choice in a `MenuRadioGroup`. The dot renders only while it is checked. */ export function MenuRadioItem({ className, children, ...props }: MenuRadioItemProps) { return ( - + {children} {/* Fixed box so a checked and an unchecked row keep the same width. */} @@ -246,7 +249,7 @@ export function MenuCheckboxItem({ ...props }: StyledProps) { return ( - + {children} ✓ diff --git a/packages/studio/src/components/ui/index.ts b/packages/studio/src/components/ui/index.ts index aac1aa360f..fc3f136996 100644 --- a/packages/studio/src/components/ui/index.ts +++ b/packages/studio/src/components/ui/index.ts @@ -17,6 +17,7 @@ export { MenuRadioItem, MenuSeparator, MenuShortcut, + menuItemBase, popupSurface, } from "./Menu"; export type { MenuItemTone, PopupPreviewState } from "./Menu"; diff --git a/packages/studio/src/ui.ts b/packages/studio/src/ui.ts index eb1ed422d0..a5e663b3ce 100644 --- a/packages/studio/src/ui.ts +++ b/packages/studio/src/ui.ts @@ -15,6 +15,7 @@ export { MenuRadioItem, MenuSeparator, MenuShortcut, + menuItemBase, popupSurface, } from "./components/ui/Menu"; export type { MenuItemTone, PopupPreviewState } from "./components/ui/Menu";