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

Missing confirm to exit unsaved binding changes #1571

Closed oliviertassinari closed 1 year ago

oliviertassinari commented 1 year ago

Duplicates

Latest version

Steps to reproduce 🕹

Steps:

  1. Open https://master--toolpad.mui.com/_toolpad/app/cld06azhx0001k59tpypy3aoy/pages/mu03mbo
  2. Select the Text element
  3. Click on "Update value binding"
  4. Make a change
  5. Press Escape

Same behavior for:

Current behavior 😯

No confirmation to exit.

Expected behavior 🤔

Confirmation before exiting.

Context 🔦

I lost some of my changes because of this behavior. I press escape to hide this popup:

Screenshot 2023-01-17 at 16 53 16

expecting that it would hide it? But instead, it exited the binding modal. This is how I found this regression (I assume it's one). And yes, it would be great for an escape to not trigger the exit action in this case, as it does with this different popup:

Screenshot 2023-01-17 at 16 54 35

Your environment 🌎

v0.0.35

Janpot commented 1 year ago

Possible road to a solution: disableEscapeKeyDown on the dialog, when the monaco editor has focus, or, if possible, only when it's displaying an autocomplete menu.

We could potentially also think about an extra confirmation when the dialog closes without saving.

oliviertassinari commented 1 year ago

confirmation when the dialog closes without saving

I have added the "regression" label because I thought it was behaving like this before. So I think that this one would be a great start since the data isn't saved live.

Janpot commented 1 year ago

I have added the "regression" label because I thought it was behaving like this before.

This dialog hasn't had a confirmation before. it's not a regression, but worthy of an integration test anyway

prakhargupta1 commented 1 year ago

The binding editor also disappears when you click on the background. During the meeting, we also saw that somehow the alert box was not working correctly.

apedroferreira commented 1 year ago

the alert box was not working correctly

Can you specify more about this please? I couldn't get some parts of the discussion because my connection has been so bad :D

Edit: Ok I just noticed that while leaving a code component editor with unsaved changes, the confirmation popup has a weird behavior when we press "Cancel". Might be related with the recent changes to navigation.

Janpot commented 1 year ago

Known problems:

apedroferreira commented 1 year ago

~~Thanks! My current approach should be able to fix all of these. But I'm also seeing if I can split the DomLoader in two separate files/concepts, because since we added undo/redo it's also handling "app state" (selections, current view) instead of just the DOM save state.~~

Edit: Oops, I meant this comment in the PR, it's a bit unrelated to the issue itself.

apedroferreira commented 1 year ago

The query editor: I should be able to press cancel in the dialog without getting the confirmation

It feels useful to me that a draft query (one that hasn't been saved for the first time yet) shows a confirmation to the user if there are unsaved changes? So I won't change anything for queries unless I misunderstood.

Janpot commented 1 year ago

My reasoning would be that by pressing "cancel", the user did a conscious action to discard the unsaved work and close the editor. Unlike clicking the background, or a browser gesture, or the Esc key. Which may have been activated inadvertedly. So a confirmation on that specific action only adds friction in most of the cases. But this could be opinionated.

apedroferreira commented 1 year ago

My reasoning would be that by pressing "cancel", the user did a conscious action to discard the unsaved work and close the editor. Unlike clicking the background, or a browser gesture, or the Esc key. Which may have been activated inadvertedly. So a confirmation on that specific action only adds friction in most of the cases. But this could be opinionated.

Ah, I see your point, because clicking "Cancel" is a bit more explicit than just switching to a different view or clicking the background. Ok, we can start by assuming than clicking "Cancel" is always intentional, I think that's fair.