zesty-io / manager-ui

Content platform powering enterprise websites and applications
https://www.zesty.io
Other
40 stars 6 forks source link

Create new item page always makes a new draft after creating an item #2726

Closed agalin920 closed 2 months ago

agalin920 commented 4 months ago

Steps to reproduce the behavior:

  1. Go to content item creation page
  2. Save the item
  3. Go to the multi item table
  4. Observe a new draft item was created even tho one was just created

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

finnar-bin commented 4 months ago

Seems like the issue happens when after creating a new content item and before the user gets redirected to the new content item dispatch(generateItem(modelZUID)) is being triggered again. I've noticed that prior to the redirection, the fields get cleared out while still on the create item page which causes the generateItem function to be re-triggered since that function lives inside a use effect that checks if the item is empty on page load.

https://github.com/zesty-io/manager-ui/blob/2b091195d333646c1dab95a2282f727ffd25c806/src/apps/content-editor/src/app/views/ItemCreate/ItemCreate.tsx#L102C1-L107C25