final-form / react-final-form-listeners

A collection of components to listen to 🏁 React Final Form fields
MIT License
93 stars 20 forks source link

OnBlur doesn't work #24

Open AbhayShiro opened 4 years ago

AbhayShiro commented 4 years ago

What is the current behavior?

https://codesandbox.io/s/52q597j2p

Try OnBlur event here. It doesnt fire the children function when element loses focus.

` const WhenFieldChanges = ({ field, becomes, set, to }) => (

{( // No subscription. We only use Field to get to the change function { input: { onChange } } ) => ( {({ form }) => ( {value => { if (value === becomes) { onChange(to); } }} { () => { console.info("got blurred sdhfghjdsgfhdsgfsdfdsjh") } } )} )}

);`

It would be nice if u provide a working example.

abrad45 commented 4 years ago

OnBlur works fine when the element called by WhenFieldChanges is blurred.

https://codesandbox.io/s/react-final-form-declarative-form-rules-forked-z67ux?file=/src/index.js