From 813f79f0f98e7db296ce33c052ed1b407f44d51d Mon Sep 17 00:00:00 2001
From: psychedelicious <4822129+psychedelicious@users.noreply.github.com>
Date: Fri, 9 Jun 2023 17:33:17 +1000
Subject: [PATCH 1/3] feat(ui): remove clear temp folder canvas button
This button is nonfunctional.
Soon we will introduce a different way to handle clearing out intermediate images (likely automated).
---
.../IAICanvasSettingsButtonPopover.tsx | 2 -
.../components/ClearTempFolderButtonModal.tsx | 41 -------------------
.../UnifiedCanvasSettings.tsx | 2 -
3 files changed, 45 deletions(-)
delete mode 100644 invokeai/frontend/web/src/features/system/components/ClearTempFolderButtonModal.tsx
diff --git a/invokeai/frontend/web/src/features/canvas/components/IAICanvasToolbar/IAICanvasSettingsButtonPopover.tsx b/invokeai/frontend/web/src/features/canvas/components/IAICanvasToolbar/IAICanvasSettingsButtonPopover.tsx
index 638332809c..ae03df8409 100644
--- a/invokeai/frontend/web/src/features/canvas/components/IAICanvasToolbar/IAICanvasSettingsButtonPopover.tsx
+++ b/invokeai/frontend/web/src/features/canvas/components/IAICanvasToolbar/IAICanvasSettingsButtonPopover.tsx
@@ -16,7 +16,6 @@ import {
setShouldShowIntermediates,
setShouldSnapToGrid,
} from 'features/canvas/store/canvasSlice';
-import EmptyTempFolderButtonModal from 'features/system/components/ClearTempFolderButtonModal';
import { isEqual } from 'lodash-es';
import { ChangeEvent } from 'react';
@@ -159,7 +158,6 @@ const IAICanvasSettingsButtonPopover = () => {
onChange={(e) => dispatch(setShouldAntialias(e.target.checked))}
/>
-
);
diff --git a/invokeai/frontend/web/src/features/system/components/ClearTempFolderButtonModal.tsx b/invokeai/frontend/web/src/features/system/components/ClearTempFolderButtonModal.tsx
deleted file mode 100644
index a220c93b3f..0000000000
--- a/invokeai/frontend/web/src/features/system/components/ClearTempFolderButtonModal.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-// import { emptyTempFolder } from 'app/socketio/actions';
-import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
-import IAIAlertDialog from 'common/components/IAIAlertDialog';
-import IAIButton from 'common/components/IAIButton';
-import { isStagingSelector } from 'features/canvas/store/canvasSelectors';
-import {
- clearCanvasHistory,
- resetCanvas,
-} from 'features/canvas/store/canvasSlice';
-import { useTranslation } from 'react-i18next';
-import { FaTrash } from 'react-icons/fa';
-
-const EmptyTempFolderButtonModal = () => {
- const isStaging = useAppSelector(isStagingSelector);
- const dispatch = useAppDispatch();
- const { t } = useTranslation();
-
- const acceptCallback = () => {
- dispatch(emptyTempFolder());
- dispatch(resetCanvas());
- dispatch(clearCanvasHistory());
- };
-
- return (
- } size="sm" isDisabled={isStaging}>
- {t('unifiedCanvas.emptyTempImageFolder')}
-
- }
- >
-
{t('unifiedCanvas.emptyTempImagesFolderMessage')}
-
- {t('unifiedCanvas.emptyTempImagesFolderConfirm')}
-
- );
-};
-export default EmptyTempFolderButtonModal;
diff --git a/invokeai/frontend/web/src/features/ui/components/tabs/UnifiedCanvas/UnifiedCanvasBeta/UnifiedCanvasToolSettings/UnifiedCanvasSettings.tsx b/invokeai/frontend/web/src/features/ui/components/tabs/UnifiedCanvas/UnifiedCanvasBeta/UnifiedCanvasToolSettings/UnifiedCanvasSettings.tsx
index a173211258..a179a95c3f 100644
--- a/invokeai/frontend/web/src/features/ui/components/tabs/UnifiedCanvas/UnifiedCanvasBeta/UnifiedCanvasToolSettings/UnifiedCanvasSettings.tsx
+++ b/invokeai/frontend/web/src/features/ui/components/tabs/UnifiedCanvas/UnifiedCanvasBeta/UnifiedCanvasToolSettings/UnifiedCanvasSettings.tsx
@@ -12,7 +12,6 @@ import {
setShouldShowCanvasDebugInfo,
setShouldShowIntermediates,
} from 'features/canvas/store/canvasSlice';
-import EmptyTempFolderButtonModal from 'features/system/components/ClearTempFolderButtonModal';
import { FaWrench } from 'react-icons/fa';
@@ -105,7 +104,6 @@ const UnifiedCanvasSettings = () => {
onChange={(e) => dispatch(setShouldAntialias(e.target.checked))}
/>
-
);
From 68be95acbb546e3dae8039e75fc8356a93c06681 Mon Sep 17 00:00:00 2001
From: psychedelicious <4822129+psychedelicious@users.noreply.github.com>
Date: Fri, 9 Jun 2023 17:55:11 +1000
Subject: [PATCH 2/3] fix(ui): fix canvas not filling screen on first load
---
invokeai/frontend/web/src/app/components/App.tsx | 10 +++++++++-
.../web/src/features/canvas/store/canvasSlice.ts | 10 +++++++++-
.../tabs/UnifiedCanvas/UnifiedCanvasContent.tsx | 2 --
3 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/invokeai/frontend/web/src/app/components/App.tsx b/invokeai/frontend/web/src/app/components/App.tsx
index bb2f140716..ddc6dace27 100644
--- a/invokeai/frontend/web/src/app/components/App.tsx
+++ b/invokeai/frontend/web/src/app/components/App.tsx
@@ -22,6 +22,7 @@ import { APP_HEIGHT, APP_WIDTH } from 'theme/util/constants';
import GlobalHotkeys from './GlobalHotkeys';
import Toaster from './Toaster';
import DeleteImageModal from 'features/gallery/components/DeleteImageModal';
+import { requestCanvasRescale } from 'features/canvas/store/thunks/requestCanvasScale';
const DEFAULT_CONFIG = {};
@@ -66,10 +67,17 @@ const App = ({
setIsReady(true);
}
+ if (isApplicationReady) {
+ // TODO: This is a jank fix for canvas not filling the screen on first load
+ setTimeout(() => {
+ dispatch(requestCanvasRescale());
+ }, 200);
+ }
+
return () => {
setIsReady && setIsReady(false);
};
- }, [isApplicationReady, setIsReady]);
+ }, [dispatch, isApplicationReady, setIsReady]);
return (
<>
diff --git a/invokeai/frontend/web/src/features/canvas/store/canvasSlice.ts b/invokeai/frontend/web/src/features/canvas/store/canvasSlice.ts
index 4742de0483..dc86783642 100644
--- a/invokeai/frontend/web/src/features/canvas/store/canvasSlice.ts
+++ b/invokeai/frontend/web/src/features/canvas/store/canvasSlice.ts
@@ -30,7 +30,10 @@ import {
} from './canvasTypes';
import { ImageDTO } from 'services/api';
import { sessionCanceled } from 'services/thunks/session';
-import { setShouldUseCanvasBetaLayout } from 'features/ui/store/uiSlice';
+import {
+ setActiveTab,
+ setShouldUseCanvasBetaLayout,
+} from 'features/ui/store/uiSlice';
import { imageUrlsReceived } from 'services/thunks/image';
export const initialLayerState: CanvasLayerState = {
@@ -857,6 +860,11 @@ export const canvasSlice = createSlice({
builder.addCase(setShouldUseCanvasBetaLayout, (state, action) => {
state.doesCanvasNeedScaling = true;
});
+
+ builder.addCase(setActiveTab, (state, action) => {
+ state.doesCanvasNeedScaling = true;
+ });
+
builder.addCase(imageUrlsReceived.fulfilled, (state, action) => {
const { image_name, image_origin, image_url, thumbnail_url } =
action.payload;
diff --git a/invokeai/frontend/web/src/features/ui/components/tabs/UnifiedCanvas/UnifiedCanvasContent.tsx b/invokeai/frontend/web/src/features/ui/components/tabs/UnifiedCanvas/UnifiedCanvasContent.tsx
index 1fadd0ada5..898f7db839 100644
--- a/invokeai/frontend/web/src/features/ui/components/tabs/UnifiedCanvas/UnifiedCanvasContent.tsx
+++ b/invokeai/frontend/web/src/features/ui/components/tabs/UnifiedCanvas/UnifiedCanvasContent.tsx
@@ -55,8 +55,6 @@ const UnifiedCanvasContent = () => {
});
useLayoutEffect(() => {
- dispatch(requestCanvasRescale());
-
const resizeCallback = () => {
dispatch(requestCanvasRescale());
};
From 93f3658a4a79a35c2294f20981d1b9920911d5d2 Mon Sep 17 00:00:00 2001
From: psychedelicious <4822129+psychedelicious@users.noreply.github.com>
Date: Fri, 9 Jun 2023 18:20:52 +1000
Subject: [PATCH 3/3] fix(ui): blur tab on click
Fixes issue where after clicking a tab, using the arrow keys changes tab instead of changing selected image
---
.../src/features/ui/components/InvokeTabs.tsx | 20 ++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/invokeai/frontend/web/src/features/ui/components/InvokeTabs.tsx b/invokeai/frontend/web/src/features/ui/components/InvokeTabs.tsx
index c164b87515..b566967b7c 100644
--- a/invokeai/frontend/web/src/features/ui/components/InvokeTabs.tsx
+++ b/invokeai/frontend/web/src/features/ui/components/InvokeTabs.tsx
@@ -14,7 +14,7 @@ import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { setIsLightboxOpen } from 'features/lightbox/store/lightboxSlice';
import { InvokeTabName } from 'features/ui/store/tabMap';
import { setActiveTab, togglePanels } from 'features/ui/store/uiSlice';
-import { memo, ReactNode, useCallback, useMemo } from 'react';
+import { memo, MouseEvent, ReactNode, useCallback, useMemo } from 'react';
import { useHotkeys } from 'react-hotkeys-hook';
import { MdDeviceHub, MdGridOn } from 'react-icons/md';
import { GoTextSize } from 'react-icons/go';
@@ -47,22 +47,22 @@ export interface InvokeTabInfo {
const tabs: InvokeTabInfo[] = [
{
id: 'txt2img',
- icon: ,
+ icon: ,
content: ,
},
{
id: 'img2img',
- icon: ,
+ icon: ,
content: ,
},
{
id: 'unifiedCanvas',
- icon: ,
+ icon: ,
content: ,
},
{
id: 'nodes',
- icon: ,
+ icon: ,
content: ,
},
];
@@ -119,6 +119,12 @@ const InvokeTabs = () => {
}
}, [dispatch, activeTabName]);
+ const handleClickTab = useCallback((e: MouseEvent) => {
+ if (e.target instanceof HTMLElement) {
+ e.target.blur();
+ }
+ }, []);
+
const tabs = useMemo(
() =>
enabledTabs.map((tab) => (
@@ -128,7 +134,7 @@ const InvokeTabs = () => {
label={String(t(`common.${tab.id}` as ResourceKey))}
placement="end"
>
-
+
{String(t(`common.${tab.id}` as ResourceKey))}
@@ -136,7 +142,7 @@ const InvokeTabs = () => {
)),
- [t, enabledTabs]
+ [enabledTabs, t, handleClickTab]
);
const tabPanels = useMemo(