Replies: 7 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}
/>
)}
/> |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for your message, unfortunately it's still not working. |
Beta Was this translation helpful? Give feedback.
-
|
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. |
Beta Was this translation helpful? Give feedback.
-
|
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. |
Beta Was this translation helpful? Give feedback.
-
|
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. |
Beta Was this translation helpful? Give feedback.
-
|
I will take a look at you links, thanks. |
Beta Was this translation helpful? Give feedback.
-
|
The HTML change event is triggered from input event bubbling. Even without RHF, it probably wouldn't be triggered by |
Beta Was this translation helpful? Give feedback.
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
Beta Was this translation helpful? Give feedback.
All reactions