History

fix(web): align thread details panel controls and menus (#3606)

maria committed 4 months ago

Commit 7bf0a2c1 parent 2f774f811 files · +81 −19Browse files

Showing the changes to apps/web/src/components/ProjectScriptsControl.tsx (1 of 11 files). Show all

Unified · Split

apps/web/src/components/ProjectScriptsControl.tsx+10−2
@@ -63,6 +63,7 @@ import { cn } from "~/lib/utils"; · 62 unmodified lines
6363 import {
6464 THREAD_DETAILS_PANEL_CHEVRON_CLASS,
6565 THREAD_DETAILS_PANEL_ICON_CLASS,
66+ THREAD_DETAILS_PANEL_ROW_POPUP_CLASS,
6667 THREAD_DETAILS_PANEL_ROW_CLASS,
6768 THREAD_DETAILS_PANEL_SPLIT_GROUP_CLASS,
6869 THREAD_DETAILS_PANEL_SPLIT_PRIMARY_CLASS,
@@ -134,6 +135,7 @@ export default function ProjectScriptsControl({ · 65 unmodified lines
134135 }: ProjectScriptsControlProps) {
135136 const isPanel = displayMode === "panel";
136137 const ActionGroup = isPanel ? "div" : Group;
138+ const panelAnchorRef = React.useRef<HTMLDivElement | null>(null);
137139 const addScriptFormId = React.useId();
138140 const [editingScriptId, setEditingScriptId] = useState<string | null>(null);
139141 const [dialogOpen, setDialogOpen] = useState(false);
@@ -267,7 +269,9 @@ export default function ProjectScriptsControl({ · 127 unmodified lines
267269 <ActionGroup
268270 role="group"
269271 aria-label="Project scripts"
270− {...(isPanel ? { className: THREAD_DETAILS_PANEL_SPLIT_GROUP_CLASS } : {})}
272+ {...(isPanel
273+ ? { className: THREAD_DETAILS_PANEL_SPLIT_GROUP_CLASS, ref: panelAnchorRef }
274+ : {})}
271275 >
272276 <Tooltip>
273277 <TooltipTrigger
@@ -316,7 +320,11 @@ export default function ProjectScriptsControl({ · 42 unmodified lines
316320 className={isPanel ? THREAD_DETAILS_PANEL_CHEVRON_CLASS : "size-4"}
317321 />
318322 </MenuTrigger>
319− <MenuPopup align="end">
323+ <MenuPopup
324+ align="end"
325+ {...(isPanel ? { anchor: panelAnchorRef } : {})}
326+ className={isPanel ? THREAD_DETAILS_PANEL_ROW_POPUP_CLASS : undefined}
327+ >
320328 {scripts.map((script) => {
321329 const shortcutLabel = shortcutLabelForCommand(
322330 keybindings,