From 13027891d949a04a15be9dbb61a256359b50ad86 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Thu, 4 Apr 2024 20:41:23 +1100 Subject: [PATCH] fix(ui): discarding last single canvas image breaks canvas We need to reset the staging area if we are discarding the last image. --- .../web/src/features/canvas/store/canvasSlice.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/invokeai/frontend/web/src/features/canvas/store/canvasSlice.ts b/invokeai/frontend/web/src/features/canvas/store/canvasSlice.ts index c5a60bdd26..68eba694ab 100644 --- a/invokeai/frontend/web/src/features/canvas/store/canvasSlice.ts +++ b/invokeai/frontend/web/src/features/canvas/store/canvasSlice.ts @@ -289,12 +289,19 @@ export const canvasSlice = createSlice({ const { images, selectedImageIndex } = state.layerState.stagingArea; pushToPrevLayerStates(state); - if (!images.length) { - return; - } - images.splice(selectedImageIndex, 1); + if (images.length === 0) { + pushToPrevLayerStates(state); + + state.layerState.stagingArea = deepClone(initialLayerState.stagingArea); + + state.futureLayerStates = []; + state.shouldShowStagingOutline = true; + state.shouldShowStagingImage = true; + state.batchIds = []; + } + if (selectedImageIndex >= images.length) { state.layerState.stagingArea.selectedImageIndex = images.length - 1; }