Skip to content

Prevent user from leaving page with incomplete form #996

Closed

Description

@benjaminleonard

It's quite easy to accidentally leave the page or close a modal before you've finished filling it out. Most notably if you're on a longer form like the instance create.

To prevent this, can we ask for confirmation to discard changes from the user. Looks like this can be done with React Router Prompt.

I can work on styling for this – to be used on both the side modals and full-page forms. Looks like this uses a native prompt dialog

Activity

  1. benjaminleonard commented on Jun 29, 2022

    @benjaminleonard
    ContributorAuthor

    Looks like Prompt is not supported in React Router 6

  2. david-crespo commented on Jun 29, 2022

    @david-crespo
    Collaborator

    As far as I can tell they're not actively working on that, but people have posted workarounds:

    remix-run/react-router#8139 (comment)

  3. benjaminleonard commented on Jun 29, 2022

    @benjaminleonard
    ContributorAuthor

    Just saw that, looks promising!

  4. just-be-dev commented on Jun 30, 2022

    @just-be-dev
    Contributor

    I'm not sure what the relative priority of this is. I added it in the first customer demo milestone given that I think @benjaminleonard is actively working on it.

  5. linked a pull request that will close this issue`use-prompt` #998on Jun 30, 2022
  6. benjaminleonard commented on Jun 30, 2022

    @benjaminleonard
    ContributorAuthor

    I started experimenting in a branch to recreate Prompt – but I am running into an error. I'll have another stab at this later.

  7. modified the milestones: Guided Demo, on Oct 22, 2022
  8. benjaminleonard commented on Jan 16, 2023

    @benjaminleonard
    ContributorAuthor

    remix-run/react-router@bb7590a

    The blocker is returning to react router 🎉

  9. added this to the MVP+1 milestone on Feb 6, 2023
  10. david-crespo commented on Feb 6, 2023

    @david-crespo
    Collaborator

    Calling it a nice to have/followup for now, open for debate. It's pretty easy to do now that they brought it back to RR.

  11. benjaminleonard commented on Feb 28, 2023

    @benjaminleonard
    ContributorAuthor

    Did a little test and is easy enough to add using formState.isDirty and useBlocker — but first we'll need a regular modal component for the popup.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions