Skip to content

feat: improved url and form state sync #736

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

manbhav234
Copy link

This PR resolves #203

This is a cleaner, easy to maintain and more scalable solution to implement this feature compared to #722

Explanation of the proposed solution:

  1. A seperate custom hook to sync url with form state
  2. Use of JSON.stringify and JSON.parse API to generate the form url which ensures real time updates in the form gets highlighted in the url for user feedback
  3. Lodash to compare the url state with default form state so that a clean url is rendered if the user directly open the app instead of opening it from a form
  4. A single common API - updateFieldValue() to update and sync the form field value changes with the url, which seamlessly integrates with the form rendering logic. This makes it easier to sync fields that may be added in the future.
  5. Custom API's to handle complex form fields like Species, which is an array of objects.

This is a demo video of the final feature:

url.form.sync.mp4

Copy link

vercel bot commented Mar 28, 2025

@manbhav234 is attempting to deploy a commit to the Main Team on Vercel.

A member of the Team first needs to authorize it.

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.

Prefill components from url ?
1 participant