Skip to content

Commit 7566d0d

Browse files
cursoragenthipsterusername
authored andcommitted
Enhance workflow mode toggle with panel navigation and focus
Co-authored-by: kent <kent@invoke.ai>
1 parent f123888 commit 7566d0d

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

invokeai/frontend/web/src/features/nodes/components/sidePanel/WorkflowViewEditToggleButton.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { IconButton } from '@invoke-ai/ui-library';
22
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
33
import { selectWorkflowMode, workflowModeChanged } from 'features/nodes/store/workflowLibrarySlice';
4+
import { useAutoLayoutContext } from 'features/ui/layouts/auto-layout-context';
5+
import { VIEWER_PANEL_ID, WORKSPACE_PANEL_ID } from 'features/ui/layouts/shared';
6+
import { setActiveTab } from 'features/ui/store/uiSlice';
47
import type { MouseEventHandler } from 'react';
58
import { memo, useCallback } from 'react';
69
import { useTranslation } from 'react-i18next';
@@ -10,21 +13,30 @@ export const WorkflowViewEditToggleButton = memo(() => {
1013
const dispatch = useAppDispatch();
1114
const mode = useAppSelector(selectWorkflowMode);
1215
const { t } = useTranslation();
16+
const { focusPanel } = useAutoLayoutContext();
1317

1418
const onClickEdit = useCallback<MouseEventHandler<HTMLButtonElement>>(
1519
(e) => {
1620
e.stopPropagation();
21+
// Navigate to workflows tab and focus the Workflow Editor panel
22+
dispatch(setActiveTab('workflows'));
1723
dispatch(workflowModeChanged('edit'));
24+
// Focus the Workflow Editor panel
25+
focusPanel(WORKSPACE_PANEL_ID);
1826
},
19-
[dispatch]
27+
[dispatch, focusPanel]
2028
);
2129

2230
const onClickView = useCallback<MouseEventHandler<HTMLButtonElement>>(
2331
(e) => {
2432
e.stopPropagation();
33+
// Navigate to workflows tab and focus the Image Viewer panel
34+
dispatch(setActiveTab('workflows'));
2535
dispatch(workflowModeChanged('view'));
36+
// Focus the Image Viewer panel
37+
focusPanel(VIEWER_PANEL_ID);
2638
},
27-
[dispatch]
39+
[dispatch, focusPanel]
2840
);
2941

3042
if (mode === 'view') {

0 commit comments

Comments
 (0)