diff --git a/invokeai/frontend/web/src/features/canvas/components/IAICanvas.tsx b/invokeai/frontend/web/src/features/canvas/components/IAICanvas.tsx index 4f9e47282d..4a67898942 100644 --- a/invokeai/frontend/web/src/features/canvas/components/IAICanvas.tsx +++ b/invokeai/frontend/web/src/features/canvas/components/IAICanvas.tsx @@ -154,6 +154,8 @@ const IAICanvas = () => { resizeObserver.observe(containerRef.current); + dispatch(canvasResized(containerRef.current.getBoundingClientRect())); + return () => { resizeObserver.disconnect(); }; diff --git a/invokeai/frontend/web/src/features/canvas/util/calculateScale.ts b/invokeai/frontend/web/src/features/canvas/util/calculateScale.ts index 954c36869c..255cb2850b 100644 --- a/invokeai/frontend/web/src/features/canvas/util/calculateScale.ts +++ b/invokeai/frontend/web/src/features/canvas/util/calculateScale.ts @@ -8,7 +8,7 @@ const calculateScale = ( const scaleX = (containerWidth * padding) / contentWidth; const scaleY = (containerHeight * padding) / contentHeight; const scaleFit = Math.min(1, Math.min(scaleX, scaleY)); - return scaleFit; + return scaleFit ? scaleFit : 1; }; export default calculateScale; diff --git a/invokeai/frontend/web/src/features/gallery/components/ImageContextMenu/SingleSelectionMenuItems.tsx b/invokeai/frontend/web/src/features/gallery/components/ImageContextMenu/SingleSelectionMenuItems.tsx index e5b9d94578..c50b0c13dd 100644 --- a/invokeai/frontend/web/src/features/gallery/components/ImageContextMenu/SingleSelectionMenuItems.tsx +++ b/invokeai/frontend/web/src/features/gallery/components/ImageContextMenu/SingleSelectionMenuItems.tsx @@ -37,6 +37,7 @@ import { import { ImageDTO } from 'services/api/types'; import { configSelector } from '../../../system/store/configSelectors'; import { sentImageToCanvas, sentImageToImg2Img } from '../../store/actions'; +import { flushSync } from 'react-dom'; type SingleSelectionMenuItemsProps = { imageDTO: ImageDTO; @@ -115,8 +116,10 @@ const SingleSelectionMenuItems = (props: SingleSelectionMenuItemsProps) => { const handleSendToCanvas = useCallback(() => { dispatch(sentImageToCanvas()); + flushSync(() => { + dispatch(setActiveTab('unifiedCanvas')); + }); dispatch(setInitialCanvasImage(imageDTO)); - dispatch(setActiveTab('unifiedCanvas')); toaster({ title: t('toast.sentToUnifiedCanvas'),