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

Detect exit intent when editing Profile, and prompt before navigating away #42

Open
gaswirth opened this issue Jun 14, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@gaswirth
Copy link
Contributor

There is already functionality in place to detect whether a Profile has edits, currently used to enable/disable the Save button. This should be taken one more step to prompt the user before refreshing/reloading, or navigating away and losing edited form data.

@gaswirth gaswirth added the enhancement New feature or request label Jun 14, 2023
@stephenscript
Copy link

I took a look into this and would like to propose an implementation using react-router Prompt and some native DOM events to prevent navigation away / closing if there are unsaved changes. I would use the hasEditedProfile state you mentioned to conditionally block navigation with a warning toast message.

I'm happy to claim this enhancement ticket and get to work. I'll update here as development ensues.

@gaswirth
Copy link
Contributor Author

gaswirth commented Jul 17, 2023

Great thought, but one issue -- I believe Prompt is only available in router v5, not v6. Let me know if you find that's not the case, but I'm fairly sure Prompt was removed after v5.

@stephenscript
Copy link

Ah, you're right. How strange. Looks like I'll have to build the functionality myself. More fun for me! I think I can still manage it, just with a bit more creativity. Good catch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants