input-number
input-number copied to clipboard
onChange and onBlur both trigger the onChange event
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:
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.
Hello @Linbubin, I do not change the value of the input, i simple visit and revisit the field: https://recordit.co/3TPk9y0ELX