From f803d5cf1e660a88a4850d548e7abace8303237a Mon Sep 17 00:00:00 2001 From: blessedcoolant <54517381+blessedcoolant@users.noreply.github.com> Date: Tue, 18 Jul 2023 21:00:43 +1200 Subject: [PATCH] fix: Shift O and Shift G not resizing the canvas correctly --- .../web/src/app/components/GlobalHotkeys.ts | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/invokeai/frontend/web/src/app/components/GlobalHotkeys.ts b/invokeai/frontend/web/src/app/components/GlobalHotkeys.ts index de8601b593..9827e7f2b3 100644 --- a/invokeai/frontend/web/src/app/components/GlobalHotkeys.ts +++ b/invokeai/frontend/web/src/app/components/GlobalHotkeys.ts @@ -16,10 +16,11 @@ import React, { memo } from 'react'; import { isHotkeyPressed, useHotkeys } from 'react-hotkeys-hook'; const globalHotkeysSelector = createSelector( - (state: RootState) => state.hotkeys, - (hotkeys) => { + [(state: RootState) => state.hotkeys, (state: RootState) => state.ui], + (hotkeys, ui) => { const { shift } = hotkeys; - return { shift }; + const { shouldPinParametersPanel, shouldPinGallery } = ui; + return { shift, shouldPinGallery, shouldPinParametersPanel }; }, { memoizeOptions: { @@ -36,7 +37,9 @@ const globalHotkeysSelector = createSelector( */ const GlobalHotkeys: React.FC = () => { const dispatch = useAppDispatch(); - const { shift } = useAppSelector(globalHotkeysSelector); + const { shift, shouldPinParametersPanel, shouldPinGallery } = useAppSelector( + globalHotkeysSelector + ); const activeTabName = useAppSelector(activeTabNameSelector); useHotkeys( @@ -54,24 +57,30 @@ const GlobalHotkeys: React.FC = () => { useHotkeys('o', () => { dispatch(toggleParametersPanel()); - if (activeTabName === 'unifiedCanvas') { + if (activeTabName === 'unifiedCanvas' && shouldPinParametersPanel) { dispatch(requestCanvasRescale()); } }); useHotkeys(['shift+o'], () => { dispatch(togglePinParametersPanel()); + if (activeTabName === 'unifiedCanvas') { + dispatch(requestCanvasRescale()); + } }); useHotkeys('g', () => { dispatch(toggleGalleryPanel()); - if (activeTabName === 'unifiedCanvas') { + if (activeTabName === 'unifiedCanvas' && shouldPinGallery) { dispatch(requestCanvasRescale()); } }); useHotkeys(['shift+g'], () => { dispatch(togglePinGalleryPanel()); + if (activeTabName === 'unifiedCanvas') { + dispatch(requestCanvasRescale()); + } }); useHotkeys('1', () => {