Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

fix(webv2): keep the library rail menus open once the pointer reaches them

Josh Corbett441998af3cc1
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/library/ProjectWorkflowsView.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/library/ProjectWorkflowsView.tsx
index 57fad409af..eba511f73b 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/library/ProjectWorkflowsView.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/library/ProjectWorkflowsView.tsx
@@ -455,8 +455,10 @@ const ProjectWorkflowDetailPanel = ({
{isActive ? t('workflowLibrary.activeWorkflow') : t('workflowLibrary.open')}
</Button>
<Menu.Root ids={moreActionsIds}>
- <Tooltip content={t('workflowLibrary.moreActions')} ids={moreActionsIds}>
- <Menu.Trigger asChild>
+ {/* Inside a dialog the tooltip must sit inside the menu trigger: wrapped the other way round, the
+ menu never takes focus and the first pointer move onto it closes it. */}
+ <Menu.Trigger asChild>
+ <Tooltip content={t('workflowLibrary.moreActions')} ids={moreActionsIds}>
<IconButton aria-label={t('workflowLibrary.moreActions')} size="sm" variant="outline">
<EllipsisIcon />
</IconButton>
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryDetailPanel.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryDetailPanel.tsx
index fe87133d6d..87b642a9e9 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryDetailPanel.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryDetailPanel.tsx
@@ -551,8 +551,10 @@ export const WorkflowLibraryDetailPanel = ({
</Button>
)}
<Menu.Root ids={moreActionsIds}>
- <Tooltip content={t('workflowLibrary.moreActions')} ids={moreActionsIds}>
- <Menu.Trigger asChild>
+ {/* Inside a dialog the tooltip must sit inside the menu trigger: wrapped the other way round, the
+ menu never takes focus and the first pointer move onto it closes it. */}
+ <Menu.Trigger asChild>
+ <Tooltip content={t('workflowLibrary.moreActions')} ids={moreActionsIds}>
<IconButton aria-label={t('workflowLibrary.moreActions')} size="sm" variant="outline">
<EllipsisIcon />
</IconButton>
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryDialog.browser.test.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryDialog.browser.test.tsx
index 586f392401..fa9a2a1aca 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryDialog.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryDialog.browser.test.tsx
@@ -738,6 +738,20 @@ describe('WorkflowLibraryDialog', () => {
expect(detail()?.textContent).toContain('Landscape Pass');
});
+ it('hands focus to the template rail menu it opens', async () => {
+ await openWith(LOADED_SNAPSHOT);
+ await act(() => card('wf-landscape')?.click());
+
+ const trigger = document.querySelector<HTMLElement>('[data-workflow-detail] [aria-label="More actions"]');
+ expect(trigger).not.toBeNull();
+ await act(async () => {
+ trigger?.click();
+ await settleFrame();
+ });
+
+ await vi.waitFor(() => expect(document.activeElement?.closest('[role="menu"]')).not.toBeNull(), { timeout: 2000 });
+ });
+
it('opens the rail actions for a card from a right-click and runs them', async () => {
await openWith(LOADED_SNAPSHOT);
@@ -1122,6 +1136,15 @@ describe('WorkflowLibraryDialog — This project', () => {
expect(onOpenChange).toHaveBeenCalledTimes(2);
});
+ it('hands focus to the rail menu it opens, so the pointer can move onto it without closing it', async () => {
+ await renderDialog();
+
+ await click(railMenuTrigger());
+
+ // Inside the dialog a menu that never took focus closes on the first pointer move onto it.
+ await vi.waitFor(() => expect(document.activeElement?.closest('[role="menu"]')).not.toBeNull(), { timeout: 2000 });
+ });
+
it('shows the active workflow in the rail with Open disabled, since it is already open', async () => {
await renderDialog();