edmundhung / conform

A type-safe form validation library utilizing web fundamentals to progressively enhance HTML Forms with full support for server frameworks like Remix and Next.js.
https://conform.guide
MIT License
1.8k stars 101 forks source link

feat: update field value automatically #728

Closed edmundhung closed 1 month ago

edmundhung commented 1 month ago

Fix #600.

This is an attempt to remove the need of passing the key to each input manually by updating the fields value automatically. It means:

  1. No more warnings from React when spreading the result of getInputProps(), getSelectProps() or getTextareaProps() as it will no longer include a key.
  2. The name will become the only metadata required to be set on your inputs. The initalValue is required only if you care about progressive enhancement.

The main challenge of this change is that Conform will trigger a re-render only when the subscribed metadata is changed and so we don't have a single place that will always re-render and runs the side effect we need. This PR resolves it by running the side effect everywhere we made a subscription and update the relevant fields only if the initialValue is subscribed.

changeset-bot[bot] commented 1 month ago

⚠️ No Changeset found

Latest commit: 3f72eba6ba894a916ffe938294583f83b5d2a970

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

cloudflare-pages[bot] commented 1 month ago

Deploying conform with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3f72eba
Status: ✅  Deploy successful!
Preview URL: https://d2c9f96f.conform.pages.dev
Branch Preview URL: https://field-side-effect.conform.pages.dev

View logs

edmundhung commented 1 month ago

Superseded by #729