1
1
import { IconButton } from '@invoke-ai/ui-library' ;
2
2
import { useAppDispatch , useAppSelector } from 'app/store/storeHooks' ;
3
3
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' ;
4
7
import type { MouseEventHandler } from 'react' ;
5
8
import { memo , useCallback } from 'react' ;
6
9
import { useTranslation } from 'react-i18next' ;
@@ -10,21 +13,30 @@ export const WorkflowViewEditToggleButton = memo(() => {
10
13
const dispatch = useAppDispatch ( ) ;
11
14
const mode = useAppSelector ( selectWorkflowMode ) ;
12
15
const { t } = useTranslation ( ) ;
16
+ const { focusPanel } = useAutoLayoutContext ( ) ;
13
17
14
18
const onClickEdit = useCallback < MouseEventHandler < HTMLButtonElement > > (
15
19
( e ) => {
16
20
e . stopPropagation ( ) ;
21
+ // Navigate to workflows tab and focus the Workflow Editor panel
22
+ dispatch ( setActiveTab ( 'workflows' ) ) ;
17
23
dispatch ( workflowModeChanged ( 'edit' ) ) ;
24
+ // Focus the Workflow Editor panel
25
+ focusPanel ( WORKSPACE_PANEL_ID ) ;
18
26
} ,
19
- [ dispatch ]
27
+ [ dispatch , focusPanel ]
20
28
) ;
21
29
22
30
const onClickView = useCallback < MouseEventHandler < HTMLButtonElement > > (
23
31
( e ) => {
24
32
e . stopPropagation ( ) ;
33
+ // Navigate to workflows tab and focus the Image Viewer panel
34
+ dispatch ( setActiveTab ( 'workflows' ) ) ;
25
35
dispatch ( workflowModeChanged ( 'view' ) ) ;
36
+ // Focus the Image Viewer panel
37
+ focusPanel ( VIEWER_PANEL_ID ) ;
26
38
} ,
27
- [ dispatch ]
39
+ [ dispatch , focusPanel ]
28
40
) ;
29
41
30
42
if ( mode === 'view' ) {
0 commit comments