From 56fd46a06981fa3ae96f748c477b73a47b38e910 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Fri, 23 Aug 2024 23:24:16 +1000 Subject: [PATCH] fix(ui): new rectangles don't trigger rerender --- .../web/src/features/controlLayers/store/canvasV2Slice.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/invokeai/frontend/web/src/features/controlLayers/store/canvasV2Slice.ts b/invokeai/frontend/web/src/features/controlLayers/store/canvasV2Slice.ts index b2529e9712..fa6391c1d8 100644 --- a/invokeai/frontend/web/src/features/controlLayers/store/canvasV2Slice.ts +++ b/invokeai/frontend/web/src/features/controlLayers/store/canvasV2Slice.ts @@ -266,6 +266,8 @@ export const canvasV2Slice = createSlice({ assert(false, `Cannot add a brush line to a non-drawable entity of type ${entity.type}`); } + // TODO(psyche): If we add the object without splatting, the renderer will see it as the same object and not + // re-render it (reference equality check). I don't like this behaviour. entity.objects.push({ ...brushLine, points: simplifyFlatNumbersArray(brushLine.points) }); }, entityEraserLineAdded: (state, action: PayloadAction) => { @@ -279,6 +281,8 @@ export const canvasV2Slice = createSlice({ assert(false, `Cannot add a eraser line to a non-drawable entity of type ${entity.type}`); } + // TODO(psyche): If we add the object without splatting, the renderer will see it as the same object and not + // re-render it (reference equality check). I don't like this behaviour. entity.objects.push({ ...eraserLine, points: simplifyFlatNumbersArray(eraserLine.points) }); }, entityRectAdded: (state, action: PayloadAction) => { @@ -292,7 +296,9 @@ export const canvasV2Slice = createSlice({ assert(false, `Cannot add a rect to a non-drawable entity of type ${entity.type}`); } - entity.objects.push(rect); + // TODO(psyche): If we add the object without splatting, the renderer will see it as the same object and not + // re-render it (reference equality check). I don't like this behaviour. + entity.objects.push({ ...rect }); }, entityDeleted: (state, action: PayloadAction) => { const { entityIdentifier } = action.payload;