Search code examples
javascriptreactjsreact-final-formfinal-form

why blur event not fire in react on textarea?


could you please tell me why blur event does not fire in react on textarea ?

actually, in my demo, I have one input and Textarea.i added blur event in both field . In the input field, it fired , but on textarea, it does not why?

here is my code https://codesandbox.io/s/react-final-form-simple-example-xknkd

 <div>
            <Field
              name="myField"
              component={TextArea}
              name="operatingPinCode"
              placeholder="Operating Pincodes"
              label="Operating Pincodes"
              useCacheForDOMMeasurements
              format={() => console.log("ffhhh")}
              formatOnBlur
            />
          </div>

Solution

  • You haven't passed onBlur handler for TextareaAutosize in textarea.js file

    <TextareaAutosize
      name={props.input.name}
      value={props.input.value}
      onChange={props.input.onChange}
    />
    

    So you need to add it

    <TextareaAutosize
      name={props.input.name}
      value={props.input.value}
      onChange={props.input.onChange}
      onBlur={props.input.onBlur}
    />