diff --git a/apps/web/src/components/editor/tools/brush-tool.tsx b/apps/web/src/components/editor/tools/brush-tool.tsx index 250fa2dc..22795cd1 100644 --- a/apps/web/src/components/editor/tools/brush-tool.tsx +++ b/apps/web/src/components/editor/tools/brush-tool.tsx @@ -82,10 +82,12 @@ export function useBrushTool() { const handleMouseUp = useCallback(() => { if (strokeRef.current) { - useEditorStore.setState({ - lastAction: "Brush Stroke", - _historyVersion: useEditorStore.getState()._historyVersion + 1, - }); + // Only update the label -- addObject() in handleMouseDown already + // incremented _historyVersion and recorded the pre-stroke snapshot. + // Bumping the version again would create a second history entry whose + // objects array still contains the line, so the first undo would + // restore the same objects reference and the canvas would not repaint. + useEditorStore.setState({ lastAction: "Brush Stroke" }); } strokeRef.current = null; }, []); diff --git a/apps/web/src/components/editor/tools/eraser-tool.tsx b/apps/web/src/components/editor/tools/eraser-tool.tsx index 5641898a..61f18904 100644 --- a/apps/web/src/components/editor/tools/eraser-tool.tsx +++ b/apps/web/src/components/editor/tools/eraser-tool.tsx @@ -82,10 +82,12 @@ export function useEraserTool() { const handleMouseUp = useCallback(() => { if (strokeRef.current) { - useEditorStore.setState({ - lastAction: "Eraser Stroke", - _historyVersion: useEditorStore.getState()._historyVersion + 1, - }); + // Only update the label -- addObject() in handleMouseDown already + // incremented _historyVersion and recorded the pre-stroke snapshot. + // Bumping the version again would create a second history entry whose + // objects array still contains the line, so the first undo would + // restore the same objects reference and the canvas would not repaint. + useEditorStore.setState({ lastAction: "Eraser Stroke" }); } strokeRef.current = null; }, []);