From f2d2f97546d9ae2ba4ed024d548aced598a48243 Mon Sep 17 00:00:00 2001 From: David Luzar Date: Tue, 29 Mar 2022 17:00:19 +0200 Subject: [PATCH] fix: using stale state when switching tools (#4989) --- src/components/Actions.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/Actions.tsx b/src/components/Actions.tsx index 347e34537..8806fe316 100644 --- a/src/components/Actions.tsx +++ b/src/components/Actions.tsx @@ -219,13 +219,17 @@ export const ShapesSwitcher = ({ penMode: true, }); } + const nextActiveTool = { ...activeTool, type: activeToolType }; setAppState({ - activeTool: { ...activeTool, type: activeToolType }, + activeTool: nextActiveTool, multiElement: null, selectedElementIds: {}, }); - setCursorForShape(canvas, { ...appState, activeTool }); - if (activeTool.type === "image") { + setCursorForShape(canvas, { + ...appState, + activeTool: nextActiveTool, + }); + if (activeToolType === "image") { onImageAction({ pointerType }); } },