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

feat(v2): warn public form filler when form has changed on server-side #3569

Merged
merged 2 commits into from
Mar 14, 2022

Conversation

karrui
Copy link
Contributor

@karrui karrui commented Mar 14, 2022

Problem

As originally raised by @mantariksh in #3457 (comment), we should not refresh the public form when the server state has changed. This may cause users to lose their currently filled in form fields. Instead, we should display a warning that form state has changed and the submission may fail due to such changes.

This PR implements that warning and prevents server side form changes from refreshing the current loaded form.
This is done by storing the initially fetched form and never changing it, whilst displaying a toast if the newly fetched form does change.

Possible future enhancements

The current methodology does a deep comparison between the current "cached" form and the form retrieved from the server, which may be inefficient. I don't think it will negatively impact responsiveness though, since the effect will not cause any rerenders -- even if a toast is shown a rerender is not triggered.

In the future, we may consider returning the _v prop when we retrieve the public form, a prop MongoDB exposes that declares the current version of the form, and compare that against the "cached" version for a simpler check.

Screenshots

Screenshot 2022-03-09 at 4 53 25 PM

@karrui karrui requested review from timotheeg and mantariksh March 14, 2022 05:58
@karrui karrui merged commit 540db5e into form-v2/develop Mar 14, 2022
@karrui karrui deleted the form-v2/warn-public-user-on-form-change branch March 14, 2022 08:57
@justynoh justynoh mentioned this pull request Oct 5, 2022
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.

2 participants