input-number icon indicating copy to clipboard operation
input-number copied to clipboard

onChange and onBlur both trigger the onChange event

Open tboulis opened this issue 4 years ago • 2 comments

I have a handler for the onChange event and a handler for the onBlur event. Whe the input loses focus it triggers both handlers instead of triggering only the onBlur handler:

       <InputNumber
          disabled={this.state.disabled)}
          onBlur={(e) => e.preventDefault()}
          onChange={this.handleDurationChange}
          onClick={e => e.stopPropagation()}
          precision={2}
          min={0}
          step={'0.1'}
          value={this.state.duration ? (this.state.duration / 3600).toFixed(2) : null}
        />

I've tried e.stopPropagation in the onBlur handler but nothing. Any idea why this is happening? Thanks in advance!

Versions:

tboulis avatar Apr 03 '20 17:04 tboulis

Because your input value does not meet your requirements, a transition is needed to trigger onChange. For your example, if you input 11.00, and blur, the onChange is not trigger.

Linbubin avatar Jul 02 '20 09:07 Linbubin

Hello @Linbubin, I do not change the value of the input, i simple visit and revisit the field: https://recordit.co/3TPk9y0ELX

tboulis avatar Jul 07 '20 14:07 tboulis