Replies: 8 comments
|
This is an issue with how the onChange callback is configured (which is implicit in your When spreading the See this CSB <Controller
name="tags"
control={control}
render={({ field }) => (
<Select
{...field}
value={tags.find((o) => o.value === field.value) ?? null}
onChange={(result) => {
console.log(result);
field.onChange(result.value);
}}
options={tags}
/>
)}
/> |
|
Thanks for your message, unfortunately it's still not working. |
|
Did you look at my sandbox? What behavior are you seeing? If the select's onChange handler is running, you should be able to wire it up to the field.onChange and pass the value to the form. |
|
Yes, I've looked at your sandbox and if I type something in the text input, I can see an "onChange :>> ..." message in the console, printed by the form 'onChange' callback. |
|
Got it. I misunderstood your initial request. I was looking at correctly setting up the I'm not too familiar with Depending on your use case, you could look at the RHF watch callback or subscribe callback. |
|
I will take a look at you links, thanks. |
|
The HTML change event is triggered from input event bubbling. Even without RHF, it probably wouldn't be triggered by |
|
The last question here is the actual key to this one: no, calling Looking at A native If the actual goal is reacting to value changes at the form level rather than intercepting a native DOM event, RHF's own |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Version Number
7.76.0
Codesandbox/Expo snack
https://codesandbox.io/p/sandbox/wispy-field-j8s7xv
Steps to reproduce
Editing the text input triggers onChange events as expected (see output in the console).
Choosing a tag in the second field by clicking on it doesn't trigger onChange. However when you start typing the tag name it does trigger it.
Expected behaviour
Choosing a tag should trigger the onChange event.
What browsers are you seeing the problem on?
Chrome, Firefox
Relevant log output
Code of Conduct
All reactions