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

Changing query name reset all the settings #1157

Closed oliviertassinari closed 1 year ago

oliviertassinari commented 1 year ago

Duplicates

Latest version

Current behavior 😯

All my options are lost, transformation, params, etc.

Expected behavior 🤔

The dialog keeps all the options set.

Steps to reproduce 🕹

Steps:

  1. Open https://master--toolpad.mui.com/_toolpad/app/cl7z6bymv24562awr0skxffqio/pages/ne1a0zn
  2. Click Add query
  3. Pick a "Fetch | default"
  4. Add https://api.github.com/repos/mui/mui-x/issues in the get URL.
  5. Focus the name field
  6. Change the value
  7. Blur the field 💥

https://user-images.githubusercontent.com/3165635/195729389-0aeed02e-e5f3-4ea9-9c35-b8e49f389ad9.mov

Context 🔦

I face this problem while I was building a quick UI for Greg to help us with the support on GitHub https://www.notion.so/mui-org/Set-GitHub-scope-labels-12a84fdf50e44595afc55343dac00fca#3f39c7660fc448b1a6c0f554a29a5ce2. If you are interested about the other pains I faced but I didn't open issues for you will find:

But I only open an issue for my biggest pain. BTW, I love the new query UI. Building the whole UI felt fast, I'm not sure I would have been quicker the pro-code way;

Your environment 🌎

v0.0.22

Janpot commented 1 year ago

I think this has the same root cause as https://github.com/mui/mui-toolpad/issues/1126. Tackling https://github.com/mui/mui-toolpad/issues/1126 should solve this issue as well.

oliviertassinari commented 1 year ago

It might be related: changing the name of a query doesn't ask for a confirmation:

https://user-images.githubusercontent.com/3165635/196751810-83f84f03-0b71-48e1-9998-f9f8eb34d41a.mov

Janpot commented 1 year ago

it's related. The name change input operates directly on the dom (it uses a shared component that's used throughout Toolpad). The rest of the dialog operates on a draft copy. when the dom changes the draft copy gets updated to the actual value in the dom. That's why changing the name resets the fields.

Solution: the name change input needs to operate on the draft copy as well. The part that's slightly tricky will be about how to deal with duplicate names.

apedroferreira commented 1 year ago

@Janpot I assigned this to myself because I thought I could take it but let me know if you think you should take it instead, I can find other tasks.

Janpot commented 1 year ago

I was going to take it but wanted to merge https://github.com/mui/mui-toolpad/pull/1149 first

I'll close this ticket as a duplicate of https://github.com/mui/mui-toolpad/issues/1126