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

Reset this.state.modified on form submit #74

Merged
merged 1 commit into from May 24, 2021

Conversation

notAro14
Copy link

Submiting did not make this.state.modified resetting to false again.

Issue

For example, when passing Prompt component (react-router-dom) like so

const MyForm = () => {
  const history = useHistory()
  
  const submitHandler = () => {
    const success = doSomethingWithFormItems()
    success && history.push('/somewhere/else')
  }

  return (
    <Formol onSubmit={submitHandler} extra={(state) => (<Prompt when={state.modified} />)}
      {/* ... */}
    </Formol>)
}

It will prompt the user a warning message to confirm the redirection after form submitting. This hangs
the redirection waiting for the user confirmation.

But the confirmation is implicit as soon as he clicks the submit button. Therefore there is no need to let the form in a modified state when submiting was successful.

@notAro14 notAro14 self-assigned this Mar 19, 2021
@coveralls
Copy link

coveralls commented Mar 19, 2021

Pull Request Test Coverage Report for Build 458

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 438: 0.0%
Covered Lines: 735
Relevant Lines: 735

💛 - Coveralls

@notAro14
Copy link
Author

notAro14 commented Apr 2, 2021

Poke @cmigazzi @gentooboontoo

Copy link

@cmigazzi cmigazzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍
It would be great if you could write a test 🙏 .

Submiting did not make this.state.modified resetting to false again.

Issue -> For example, when passing Prompt component (react-router-dom) like so

`<Formol extra={(this.state) => (<Prompt when={this.state.modified} />)}`

It will prompt the user a warning message to confirm the redirection after form submitting. This hangs
the redirection waiting for the user confirmation.

but the confirmation is implicit as soon as he clicks the submit button. Therefore there is no need to let the form in a modified state when
submiting was successful.
@notAro14 notAro14 force-pushed the fix-modified-state-on-submit branch from 9803a01 to 2ca3556 Compare May 24, 2021 10:40
@notAro14 notAro14 merged commit 08ea8ea into master May 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants