Custom onBlur on Field overrides default behavior
See original GitHub issueBug, Feature, or Question?
Bug/Feature
Current Behavior
a Field
with a custom onBlur
removes the default validation/touched behavior
<Field name="fname" onBlur={() => console.log("custom")} />
https://codesandbox.io/s/yk9mmj1kwx
Desired Behavior
custom onBlur
prop will be chained to the internal handleBlur
Suggested Solutions
in handleBlur
if (this.props.onBlur) this.props.onBlur()
- Formik Version: 0.11.11
- React Version: 16.2
- CodeSandbox Link: https://codesandbox.io/s/yk9mmj1kwx
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:9 (2 by maintainers)
Top Results From Across the Web
React Formik: My custom onBlur override default touched ...
I just started learning to code 2 months ago, this week I tried to work with Formik and had this issue where I...
Read more >Validate Field onBlur() using Props Bindings in mobx-react-form
If we want to override the built-in field props, we have a good chance here passing some props to the bind() method. Then...
Read more >blur() - CSS: Cascading Style Sheets - MDN Web Docs - Mozilla
The blur() CSS function applies a Gaussian blur to the input image. Its result is a <filter-function> . Try it. CSS Demo: blur()....
Read more >Custom Widgets and Fields - react-jsonschema-form documentation
You can override any default field and widget, including the internal widgets like the CheckboxWidget that ObjectField renders for boolean values.
Read more >Deep dive - Summernote
You can override the default list and specify a custom one. ... A module named editor supports several methods for editor's basic behavior...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
How about this?
props
getter would chain “overrides” props while still keeps Formik work.I’m a big fan of the approach outlined by @Andreyco. This would follow the ‘prop getters’ pattern as is outlined here: https://kentcdodds.com/blog/how-to-give-rendering-control-to-users-with-prop-getters
It’s used to great effect in https://github.com/downshift-js/downshift