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

executeBlur should not inspect event if path is set #1113

Open
danielberndt opened this issue Nov 16, 2018 · 1 comment
Open

executeBlur should not inspect event if path is set #1113

danielberndt opened this issue Nov 16, 2018 · 1 comment

Comments

@danielberndt
Copy link

🐛 Bug report

I've created a FieldWrapper that looks somewhat like this:

const MyField ({name, as: Component}) => (
  <Field name={name}>
     {({field: {onChange, onBlur, ...rest}, form}) => (
       <Component
           onBlur={onBlur(name)}
           onChange={onChange(name)}
           {...rest}
       />
   )}</Field>
)

I'm using this to wrap external Inputs. Those Inputs don't always pass an event when firing onBlur though. I expected this to be fine by formik, because I passed the name of the corresponding field explicitly.

It turns out though that the following lines still try to access the event, even though there's no need to when the path is explicitly passed.

formik/src/Formik.tsx

Lines 444 to 445 in 85d15b3

const { name, id, outerHTML } = e.target;
const field = path ? path : name ? name : id;

Is it possible/reasonable to rewrite those lines in a way that e is not accessed when the path is passed?

@jaredpalmer
Copy link
Owner

Agree, I fixed this in v2. They should use the override.

@jaredpalmer jaredpalmer mentioned this issue Dec 7, 2018
24 tasks
@johnrom johnrom added this to the v2.0 milestone May 27, 2019
@johnrom johnrom removed the v2 label May 27, 2019
@jaredpalmer jaredpalmer removed this from the v2.0.1 milestone Sep 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants