react-final-form-listeners icon indicating copy to clipboard operation
react-final-form-listeners copied to clipboard

OnBlur doesn't work

Open AbhayShiro opened this issue 5 years ago • 1 comments

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 }) => ( <Field name={set} subscription={{}}> {( // No subscription. We only use Field to get to the change function { input: { onChange } } ) => ( <FormSpy subscription={{}}> {({ form }) => ( <React.Fragment>

      <OnChange name={field}>
        {value => {
          if (value === becomes) {
            onChange(to);
          }
        }}
      </OnChange>
      <OnBlur  name={field}>
        {
          () => {
            console.info("got blurred sdhfghjdsgfhdsgfsdfdsjh")
          }
        }
      </OnBlur>
      </React.Fragment>
    )}
  </FormSpy>
)}
);`

It would be nice if u provide a working example.

AbhayShiro avatar Aug 04 '20 04:08 AbhayShiro

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

abrad45 avatar Aug 27 '20 16:08 abrad45