Skip to content

Undo & redo#229

Open
Daan0709 wants to merge 10 commits intomasterfrom
feat/undo-redo
Open

Undo & redo#229
Daan0709 wants to merge 10 commits intomasterfrom
feat/undo-redo

Conversation

@Daan0709
Copy link
Contributor

@Daan0709 Daan0709 commented Feb 13, 2026

  • You can now undo changes made to the canvas with CTRL + Z
  • You can also redo these undo changes with CTRL + SHIFT + Z or CTRL + Y
  • Changes include but are not limited to: moving nodes, deleting nodes, deleting edges, adding nodes, grouping nodes
  • A maximum of 20 changes is tracked, this is just a number that I chose cause it felt right (not too much for memory overload, but also a fair amount that can be undone)

@Daan0709 Daan0709 self-assigned this Feb 13, 2026
@Daan0709 Daan0709 marked this pull request as ready for review February 13, 2026 15:34
This was linked to issues Feb 15, 2026
Copy link
Contributor

@stijnpotters1 stijnpotters1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ik zie dat je import { subscribeWithSelector } from 'zustand/middleware' gebruikt en hierin een eigen undo redo maakt.

Ik zie dat er een aparte undo redo middleware library voor zustand is.
https://github.com/charkour/zundo

Wellicht kan je dit bekijken om te kijken of dit niet een betere oplossing is?

Comment on lines 363 to 381
if (isCmdOrCtrl && event.key.toLowerCase() === 'z') {
event.preventDefault()
// Redo if Shift is also pressed, otherwise undo
if (event.shiftKey) {
useFlowStore.getState().redo()
} else {
useFlowStore.getState().undo()
}
}

// Or redo with Cmd/Ctrl + Y, which is common on Windows
if (isCmdOrCtrl && event.key.toLowerCase() === 'y') {
event.preventDefault()
useFlowStore.getState().redo()
}

if (event.key === 'g' || event.key === 'G') {
event.preventDefault()
handleGrouping()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the only component looking for key or mouse events?
I'm thinking that maybe having an overarching system to manage key and mouse event handling could be nice since a lot of repetition might happen if this is used in multiple components

I can elaborate further but maybe its better to make an issue and let it be like this for this PR, if you agree with me here

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement redo functionality Implement undo functionality

3 participants