-
Notifications
You must be signed in to change notification settings - Fork 105
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
fix(conform-react): stops managing all inputs by default #775
base: main
Are you sure you want to change the base?
Conversation
|
More templates
@conform-to/dom
@conform-to/validitystate
@conform-to/react
@conform-to/yup
@conform-to/zod
commit: |
7f1cbb3
to
aa6253d
Compare
Deploying conform with Cloudflare Pages
|
aa6253d
to
4bb6561
Compare
4bb6561
to
3fbf4d4
Compare
shouldManageInput?: ( | ||
element: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement, | ||
) => boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't forget buttons! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conform does not manage any buttons (i.e. It should not update the button value). Is there something you want to achieve with this option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, okay, I was thinking user intent buttons (not conform intent buttons) but if thats outside this scope, please ignore my comment.
would this have any way to go back to |
Unless you are configuring the hidden inputs with helpers like You will have access to the dom element, so feel free to do any logic that makes sense to you, e.g. function Example() {
const [form, fields] = useForm({
shouldManageInput(element) {
// Ignore all inputs with `address.` as the prefix
return !element.name.startsWith('address.');
// Ignore all hidden inputs
return element.type !== 'hidden';
// Otherwise, turn it off completely
return false;
}
});
// ...
} |
3fbf4d4
to
b95eb3d
Compare
@edmundhung this works for me! 👍🏻 |
Some people might still consider this a breaking change if they use the helper functions to configure inputs. One alternative could be to make this entirely opt-in for v1 and switch to opt-out in v2. However, that would mean the helpers would still return the key property and trigger the React warning. To avoid confusion, I might just deprecate the helpers now, as they don't integrate well with component libraries. I'd rather clearly define the properties they should pass to inputs and encourage them to create their own helpers to fit their needs. |
@edmundhung I'd be open to that, however there should be some dedicated types exposed for things like the return value of |
Fix #729
Related Issues:
This stops Conform from managing all inputs, except those that are configured with
getInputProps
,getSelectProps
andgetTextareaProps
. You can customize the behavior by settingshouldManagerInput
on theuseForm
hook, e.g.If we decide to go with this solution, we can also deprecate
shouldDirtyConsider
later as it could be derived based on the result ofshouldManageInput
.Todos: