Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMS 5: React context no longer has "You have unsaved changes" confirm dialog #1409

Closed
3 tasks done
GuySartorelli opened this issue Dec 11, 2022 · 1 comment
Closed
3 tasks done

Comments

@GuySartorelli
Copy link
Member

GuySartorelli commented Dec 11, 2022

#1312 results in some regressions which we've decided to handle as separate issues. This is one of those.

React contexts (such as asset-admin and possibly campaign-admin) used to have a "You have unsaved changes" confirm dialog which would be triggered if you tried to navigate away without saving your changes. This was part of react-router, but that functionality is not included with react-router 6.x - so we need to implement it another way.

Acceptance criteria

  • When a user has unsaved changes and tries to navigate in a react context, a confirm dialog is presented asking if they way to navigate away or not
  • If the user selects "no" or "cancel" they do not navigate away and can save their changes
  • If the user selects "yes" or "ok" they are navigated away and lose their changes

Notes

  • react-router uses history under the hood. We may be able to utilise its blocking transitions functionality. It looks like despite saying they use this under the hood, they don't actually use this.
  • react-beforeunload is another possible way to implement this This might be useful in addition to any solution we come up with, but it doesn't actually handle routing within the app, only out of it.
  • There is a lot of discussion about this along with other potential solutions in this issue thread which is where the above options came from
  • Yes we can technically downgrade to the previous version, however while that version is still maintained for now it doesn't get the same attention as v6. It's better for us to keep the upgrade if we can.

PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants