From 6c76f9b2c75288b330d0e11a7851aae560227a43 Mon Sep 17 00:00:00 2001 From: yiling Date: Wed, 4 Nov 2026 22:11:41 +0800 Subject: [PATCH] fix(webui): align submenu trigger text and widen file context menu --- .../components/file-browser/context-menu.test.tsx | 8 +++++++- .../webui/components/file-browser/context-menu.tsx | 11 +++++++---- .../webui/components/file-browser/copy-submenu.tsx | 4 ++-- .../components/file-browser/use-copy-actions.test.ts | 9 ++++++++- packages/webui/components/ui/context-menu.tsx | 2 +- 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/packages/webui/components/file-browser/context-menu.test.tsx b/packages/webui/components/file-browser/context-menu.test.tsx index 85f43010..17519fad 100644 --- a/packages/webui/components/file-browser/context-menu.test.tsx +++ b/packages/webui/components/file-browser/context-menu.test.tsx @@ -81,12 +81,18 @@ describe('FileBrowserContextMenu', () => { expect(screen.queryByText(/Manage versions|管理版本/i)).toBeNull() }) - it('renders Copy submenu trigger for regular file item', () => { + it('renders Copy submenu trigger for regular file item with aligned gap-2 and w-52 menu width', () => { renderWithMenu(fileItem) fireEvent.contextMenu(screen.getByTestId('context-trigger')) const copyOption = screen.getByText(/^Copy$|^复制$/i) expect(copyOption).toBeTruthy() + + const trigger = copyOption.closest('[data-slot="context-menu-sub-trigger"]') + expect(trigger?.className).toContain('gap-2') + + const menuContent = copyOption.closest('[data-slot="context-menu-content"]') + expect(menuContent?.className).toContain('w-52') }) }) diff --git a/packages/webui/components/file-browser/context-menu.tsx b/packages/webui/components/file-browser/context-menu.tsx index 9e41758e..0b344d1c 100644 --- a/packages/webui/components/file-browser/context-menu.tsx +++ b/packages/webui/components/file-browser/context-menu.tsx @@ -160,7 +160,7 @@ export function FileBrowserContextMenu({ if (isShareView) { if (!item) return null return ( - + {m.download()} @@ -183,7 +183,7 @@ export function FileBrowserContextMenu({ return null } return ( - + {m.restore()} @@ -197,6 +197,7 @@ export function FileBrowserContextMenu({ // Right-click on empty area return ( { e.preventDefault() }} @@ -224,6 +225,7 @@ export function FileBrowserContextMenu({ const contextMenuContent = isItemSelected && selectedIds.size > 1 ? ( { e.preventDefault() }} @@ -292,7 +294,7 @@ export function FileBrowserContextMenu({ {m.add_to_share_links()} - + {shareLinks.map((share) => ( ) : ( { e.preventDefault() }} @@ -411,7 +414,7 @@ export function FileBrowserContextMenu({ {m.add_to_share_links()} - + {shareLinks.map((share) => ( {m.copy()} - + {imageOpt && ( <> onCopy('image', items)}> @@ -163,7 +163,7 @@ export function CopyDropdownMenuSub({ items, context, onCopy }: CopyMenuProps) { {m.copy()} - + {imageOpt && ( <> { updatedAt: '2026-01-01', media: { imageTranscodes: [ - { id: 't1', url: '', key: 'files/img1/proxy-768p.webp', width: 768, height: 1024, size: 500 }, + { + id: 't1', + url: '', + key: 'files/img1/proxy-768p.webp', + width: 768, + height: 1024, + size: 500, + }, ], }, } diff --git a/packages/webui/components/ui/context-menu.tsx b/packages/webui/components/ui/context-menu.tsx index 9f7f96dc..d18df00b 100644 --- a/packages/webui/components/ui/context-menu.tsx +++ b/packages/webui/components/ui/context-menu.tsx @@ -47,7 +47,7 @@ function ContextMenuSubTrigger({ data-slot="context-menu-sub-trigger" data-inset={inset} className={cn( - "flex cursor-default items-center rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[inset]:pl-8 data-[state=open]:bg-accent data-[state=open]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground", + "flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[inset]:pl-8 data-[state=open]:bg-accent data-[state=open]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground", className, )} {...props}