Skip to content
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

useTextField's onChange isn't firing with useFormik's formik change handler #4854

Closed
jenmak-tangelo opened this issue Aug 2, 2023 · 2 comments

Comments

@jenmak-tangelo
Copy link

jenmak-tangelo commented Aug 2, 2023

Provide a general summary of the issue here

The controlled component controlled with formik's hook, for example:

      <TextInputField
        type="tel"
        id="phone"
        name="phone"
        prefix="phone"
        label="Mobile Phone"
        value={formik.values.phone}
        onChange={formik.handleChange}
      />

Does not allow the user to input a value because of the onChange function. I suspect it is because it returns a string instead of an event.

🤔 Expected Behavior?

The onChange should return an event instead of just the target value

😯 Current Behavior

The onChange returns just the target value and is incompatible with other libraries

💁 Possible Solution

No response

🔦 Context

No response

🖥️ Steps to Reproduce

https://codesandbox.io/s/naughty-water-87jkcy?file=/src/App.js

Version

3.26.0

What browsers are you seeing the problem on?

Firefox, Chrome, Safari

If other, please specify.

No response

What operating system are you using?

Mac OS

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

@jenmak-tangelo jenmak-tangelo added the bug Something isn't working label Aug 2, 2023
@dannify dannify removed the bug Something isn't working label Aug 3, 2023
@devongovett
Copy link
Member

See #1860 and #3247 for previous discussions about this. In your case, could you do something like this?

<TextInputField
  // ...
  value={formik.values.phone}
  onChange={value => formik.setFieldValue('phone', value)} />

@jenmak-tangelo
Copy link
Author

Yes that is exactly what I ended up doing. Thanks

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

No branches or pull requests

3 participants