mui / toolpad

Toolpad: Full stack components and low-code builder for dashboards and internal apps.
https://mui.com/toolpad/
MIT License
964 stars 243 forks source link

Undo/Redo action #226

Closed oliviertassinari closed 1 year ago

oliviertassinari commented 2 years ago

The very first frustration I had using the tool today is not being able to undo a change. I have tried a change that didn't work, now, I'm not sure how to get back to the previous state that was better. It doesn't incentive me to experiment.

To do:

How do other tools push to history when typing text?

debounce throttle word delimiters
google docs
notion
vscode
figma
prakhargupta1 commented 2 years ago

To get some idea on how Undo and Redo should work in different scenarios: https://github.com/appsmithorg/appsmith/issues/1426#issuecomment-810842190

apedroferreira commented 2 years ago

First prerequisite for undo/redo: https://github.com/mui/mui-toolpad/issues/845

bytasv commented 1 year ago

As a follow up to https://github.com/mui/mui-toolpad/pull/1225 we should make following UX improvement:

High level pseudo-code proposal:

function getViewForDom(dom: AppDom): ToolpadView
function isSameView(view1: ToolpadView, view2: ToolpadView): boolean
function navigateToView(ToolpadView): void
apedroferreira commented 1 year ago

High level pseudo-code proposal:

Maybe focusOnView instead of navigateToView? Other than that sounds good if we need this type of solution.

Janpot commented 1 year ago

This was just some pseudo-code to illustrate an idea, I didn't intend for this to be used as a starting point or anything.

oliviertassinari commented 1 year ago

https://user-images.githubusercontent.com/3165635/201174983-5b2f95b7-0a90-4d9e-a1af-2afeef9a8855.mov

When I press Cmd+Z key, it undo 2 actions, not one. In the same way, when I press the shortcut to redo my change after the undo, it doesn't work. It seems that undo/redo is strongly tight to what is committed on the backend. I think that it would be great to decorrelate the two notions. Fixed in #1328

Screenshot 2022-11-10 at 19 41 15

Or Figma, even better:

Screenshot 2022-11-10 at 19 42 19 Screenshot 2022-11-10 at 19 42 32
bytasv commented 1 year ago

The undo / redo has a bug

@oliviertassinari thanks, that's a great catch. I already found the cause - it happens because throttled undo stack update is triggered after we undo action which messes up the state. I have one working solution to the issue that makes situation way better, but not perfect yet, I should post an update soon

I don't think that the undo/redo button will ever be used more than 5% of the time, I think that it could be hidden from the interface, into a submenu like notion has

I do agree, I could just remove the buttons. @gerdadesign any issues from your end if we remove the buttons? Maybe you could share what was the motivation of having them designed in the UI? Maybe we are missing some important details?

oliviertassinari commented 1 year ago
gerdadesign commented 1 year ago

I do agree, I could just remove the buttons. @gerdadesign any issues from your end if we remove the buttons? Maybe you could share what was the motivation of having them designed in the UI? Maybe we are missing some important details?

This seems fine. For context:

So, especially for a tech-fluent audience, I think that keyboard shortcut would suffice. This would probably require adding Keyboard shortcuts to the Help menu:

_HelpMenu

and then from there, showing the list of available keyboard shortcuts

_KeyboardShortcutsMenu (1)
bytasv commented 1 year ago

I'm removing undo/redo buttons as part of https://github.com/mui/mui-toolpad/pull/1308 👍

Janpot commented 1 year ago

This has been implemented