diff --git a/invokeai/frontend/web/src/features/ui/components/InvokeTabs.tsx b/invokeai/frontend/web/src/features/ui/components/InvokeTabs.tsx index 6c683470e7..26d06adfb3 100644 --- a/invokeai/frontend/web/src/features/ui/components/InvokeTabs.tsx +++ b/invokeai/frontend/web/src/features/ui/components/InvokeTabs.tsx @@ -16,7 +16,7 @@ import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; import { requestCanvasRescale } from 'features/canvas/store/thunks/requestCanvasScale'; import ImageGalleryContent from 'features/gallery/components/ImageGalleryContent'; import { configSelector } from 'features/system/store/configSelectors'; -import { InvokeTabName } from 'features/ui/store/tabMap'; +import { InvokeTabName, tabMap } from 'features/ui/store/tabMap'; import { setActiveTab, togglePanels } from 'features/ui/store/uiSlice'; import { ResourceKey } from 'i18next'; import { isEqual } from 'lodash-es'; @@ -172,13 +172,22 @@ const InvokeTabs = () => { const { ref: galleryPanelRef, minSizePct: galleryMinSizePct } = useMinimumPanelSize(MIN_GALLERY_WIDTH, DEFAULT_GALLERY_PCT, 'app'); + const handleTabChange = useCallback( + (index: number) => { + const activeTabName = tabMap[index]; + if (!activeTabName) { + return; + } + dispatch(setActiveTab(activeTabName)); + }, + [dispatch] + ); + return ( { - dispatch(setActiveTab(index)); - }} + onChange={handleTabChange} sx={{ flexGrow: 1, gap: 4, diff --git a/invokeai/frontend/web/src/features/ui/store/uiSlice.ts b/invokeai/frontend/web/src/features/ui/store/uiSlice.ts index 81243aa03f..e487f08067 100644 --- a/invokeai/frontend/web/src/features/ui/store/uiSlice.ts +++ b/invokeai/frontend/web/src/features/ui/store/uiSlice.ts @@ -26,7 +26,7 @@ export const uiSlice = createSlice({ name: 'ui', initialState: initialUIState, reducers: { - setActiveTab: (state, action: PayloadAction) => { + setActiveTab: (state, action: PayloadAction) => { setActiveTabReducer(state, action.payload); }, setShouldPinParametersPanel: (state, action: PayloadAction) => {