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

input.onBlur does not make field touched #22

Closed
davidhenley opened this issue Dec 3, 2017 · 2 comments
Closed

input.onBlur does not make field touched #22

davidhenley opened this issue Dec 3, 2017 · 2 comments

Comments

@davidhenley
Copy link

davidhenley commented Dec 3, 2017

input.onChange() and input.onBlur() by themselves do not make a field touched. You MUST call input.onFocus() as well as onBlur to actually make the field touched.

export const CustomerSearch = (({ input, meta, label, ...rest }) => {
  return (
    <Form.Field>
      <label>{label}</label>
      <Search
        {...input}
        {...rest}
        list={[
          { title: 'thing 1', description: 'desc 1' },
          { title: 'thing 2', description: 'desc 2' },
        ]}
        onChange={result => input.onChange(result)} // this works
        onBlur={() => input.onBlur()} // this will not mark field as touched
      />
      <div className="field-error-text">{meta.touched && meta.error}</div>
    </Form.Field>
  );
})

You have to call onFocus if you are going to call onBlur. This will make it work. onBlur by itself should make the field touched in my opinion

@davidhenley davidhenley changed the title Cannot call input.onBlur manually input.onBlur does not make field touched Dec 3, 2017
@erikras
Copy link
Member

erikras commented Dec 4, 2017

Published fix in final-form v1.2.1.

pcraig3 added a commit to cds-snc/ircc-rescheduler that referenced this issue Apr 12, 2018
Rather than coupling our components to the Field used by
React-Final-Form, we can just pass in a component to the <Field>
as long as we provide an adaptor of some kind.

Used the example at: https://codesandbox.io/s/kkmk8116y3
which was helpful.

Also these issues were useful:
- final-form/react-final-form#91
- final-form/react-final-form#22
pcraig3 added a commit to cds-snc/ircc-rescheduler that referenced this issue Apr 12, 2018
Rather than coupling our components to the Field used by
React-Final-Form, we can just pass in a component to the <Field>
as long as we provide an adaptor of some kind.

Used the example at: https://codesandbox.io/s/kkmk8116y3
which was helpful.

Also these issues were useful:
- final-form/react-final-form#91
- final-form/react-final-form#22
dsamojlenko pushed a commit to cds-snc/ircc-rescheduler that referenced this issue Sep 1, 2018
Rather than coupling our components to the Field used by
React-Final-Form, we can just pass in a component to the <Field>
as long as we provide an adaptor of some kind.

Used the example at: https://codesandbox.io/s/kkmk8116y3
which was helpful.

Also these issues were useful:
- final-form/react-final-form#91
- final-form/react-final-form#22
@lock
Copy link

lock bot commented Dec 4, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Dec 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants