fix: trigger React re-renders after DrawCommand undo/redo

DrawCommand was correctly restoring canvas state but wasn't triggering
React re-renders, causing the UI to appear unchanged. Added updateLayer()
calls with timestamp updates to both execute() and undo() methods to
ensure proper re-rendering after canvas modifications.

Fixes fill tool undo functionality and ensures all drawing operations
properly update the UI when undone/redone.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-21 09:32:22 +01:00
parent 6e35849f4e
commit 8175ab2fec

View File

@@ -43,6 +43,10 @@ export class DrawCommand extends BaseCommand {
ctx.clearRect(0, 0, layer.canvas.width, layer.canvas.height); ctx.clearRect(0, 0, layer.canvas.width, layer.canvas.height);
ctx.drawImage(this.afterCanvas, 0, 0); ctx.drawImage(this.afterCanvas, 0, 0);
// Trigger re-render by updating layer timestamp
const { updateLayer } = useLayerStore.getState();
updateLayer(this.layerId, { updatedAt: Date.now() });
} }
undo(): void { undo(): void {
@@ -56,5 +60,9 @@ export class DrawCommand extends BaseCommand {
ctx.clearRect(0, 0, layer.canvas.width, layer.canvas.height); ctx.clearRect(0, 0, layer.canvas.width, layer.canvas.height);
ctx.drawImage(this.beforeCanvas, 0, 0); ctx.drawImage(this.beforeCanvas, 0, 0);
// Trigger re-render by updating layer timestamp
const { updateLayer } = useLayerStore.getState();
updateLayer(this.layerId, { updatedAt: Date.now() });
} }
} }