diff --git a/src/components/LinuxMenuButton.test.tsx b/src/components/LinuxMenuButton.test.tsx index 95b44cff..6dff4cdc 100644 --- a/src/components/LinuxMenuButton.test.tsx +++ b/src/components/LinuxMenuButton.test.tsx @@ -21,11 +21,15 @@ vi.mock('@tauri-apps/api/window', () => ({ async function openSubmenu(label: string) { fireEvent.pointerDown(screen.getByRole('button', { name: 'Application menu' }), { button: 0 }) - const trigger = await screen.findByText(label) + const trigger = await screen.findByRole('menuitem', { name: new RegExp(label) }) fireEvent.pointerMove(trigger) fireEvent.click(trigger) } +async function openHorizontalMenu(label: string) { + fireEvent.pointerDown(screen.getByRole('button', { name: label }), { button: 0 }) +} + describe('LinuxMenuButton', () => { beforeEach(() => { vi.clearAllMocks() @@ -45,6 +49,16 @@ describe('LinuxMenuButton', () => { expect(invoke).toHaveBeenCalledWith('trigger_menu_command', { id: 'view-toggle-ai-chat' }) }, MENU_TEST_TIMEOUT_MS) + it('dispatches shared menu commands from the horizontal desktop menu', async () => { + render() + + expect(screen.getByTestId('desktop-horizontal-menu')).toBeInTheDocument() + + await openHorizontalMenu('File') + fireEvent.click(await screen.findByText('New Note')) + expect(invoke).toHaveBeenCalledWith('trigger_menu_command', { id: 'file-new-note' }) + }, MENU_TEST_TIMEOUT_MS) + it('invokes direct window actions from the Window submenu', async () => { render() diff --git a/src/components/LinuxMenuButton.tsx b/src/components/LinuxMenuButton.tsx index 8bcaf671..d9c98b49 100644 --- a/src/components/LinuxMenuButton.tsx +++ b/src/components/LinuxMenuButton.tsx @@ -47,6 +47,39 @@ function triggerMenuCommand(menuItemId: string): void { void invoke('trigger_menu_command', { id: menuItemId }).catch(() => {}) } +function MenuSectionItems({ section }: { section: MenuSection }) { + return ( + <> + {section.items.map((item, index) => { + if (item.kind === 'separator') { + return + } + + if (item.kind === 'command') { + return ( + triggerMenuCommand(item.menuItemId)} + > + {item.label} + {item.shortcut && ( + {item.shortcut} + )} + + ) + } + + return ( + + {item.label} + {item.shortcut && {item.shortcut}} + + ) + })} + + ) +} + function HamburgerIcon() { return ( @@ -57,7 +90,7 @@ function HamburgerIcon() { ) } -export function LinuxMenuButton() { +function AppMenuButton() { return ( @@ -77,32 +110,7 @@ export function LinuxMenuButton() { {section.label} - {section.items.map((item, index) => { - if (item.kind === 'separator') { - return - } - - if (item.kind === 'command') { - return ( - triggerMenuCommand(item.menuItemId)} - > - {item.label} - {item.shortcut && ( - {item.shortcut} - )} - - ) - } - - return ( - - {item.label} - {item.shortcut && {item.shortcut}} - - ) - })} + ))} @@ -110,3 +118,42 @@ export function LinuxMenuButton() { ) } + +function HorizontalMenuBar() { + return ( +
+ {MENU_SECTIONS.map((section) => ( + + + + + + + + + ))} +
+ ) +} + +export function LinuxMenuButton() { + return ( + <> +
+ +
+ + + ) +}