Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add feature to view if it can undo or redo

See original GitHub issue

I was thinking if it would be possible to add apis to check if it can undo or redo. I was thinking maybe: canUndo and canRedo which would return true or false. it would be nice to also store history change itself like: history

// returned object:
  undo: {
    depth: 3,
    changes: [
    // same for redo

Of course this is a proposal and any comment is welcome.

Or we could even attach the apis to undo and redo directly like so: undo.history or undo.depth or undo.canUndo.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:27 (15 by maintainers)

github_iconTop GitHub Comments

charkourcommented, Sep 26, 2022

Hey @vixalien and @feuersteiner,

As far as the canUndo, canRedo, undoDepth, redoDepth functionality, since those are computed values, I don’t think it is necessary to add the to main temporal store in the zundo middleware. However, I think a meta-data helper function would be useful to add so I’ll work on that.

For the time being, here is a code sandbox canUndo, canRedo, undoDepth, redoDepth that implements canUndo, canRedo, undoDepth, and redoDepth with zundo v2.

Thanks for the feedback!

skratcommented, Nov 15, 2022

If I only use the .temporal store in my component, it doesn’t get re-rendered when I call undo() or redo() because pastStates and futureStates are not changing identity (not 100% about this), they’re simply being changed in place with push and splice.

It works in your demos, because you have everything in one component, but if there’s a component that is using just the temporal state, it breaks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Undo or redo typing or design changes - Microsoft Support
You can undo and redo up to 20 of your last typing or design actions in Access. To undo an action, press Ctrl...
Read more >
Implement Undo and Redo features of a Text Editor
“REDO”: Restores the most recent UNDO operation performed on the document. “READ”: Reads and prints the contents of the documents. Examples:.
Read more >
Undo/redo and history in Adobe Photoshop
Undo or redo multiple steps in Photoshop. Use the History panel to control the state of your images in Adobe Photoshop.
Read more >
Filter undo and redo for editing—ArcGIS Pro | Documentation
On the Quick Access toolbar, you can filter the undo stack and roll back a selected range of edits without undoing mapping changes,...
Read more >
Undo or redo changes in Pages on Mac - Apple Support
You can undo recent changes you make to a document, then redo them if you change your mind. Do any of the following:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found