Add unsaved changes warning to form #714
Merged
+154
−107
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue(s) Resolved
Kind of related to #692. These changes would at least notify users if they would lose progress.
Also partially related to #445, in that it introduces a general-purpose React hook for warning about unsaved changes. The general strategy here can be used on the form builder as well.
High-level Explanation of PR
This PR changes the external form fill page to notify the user about unsaved changes when navigating. It uses the standard
beforeunload
method of notifying the user in a blocking manner, giving them the opportunity to cancel navigation.The PR accounts for autosave by clearing the "dirty" flag from the form after an auto-save occurs.
I also change the form to only submit changed values which can potentially make Pub editing w/ forms a bit snappier.
Test Plan