palantir / blueprint

A React-based UI toolkit for the web
https://blueprintjs.com/
Apache License 2.0
20.73k stars 2.18k forks source link

NumericInput clamps outside bounds with invalid input #1984

Open rafeememon opened 6 years ago

rafeememon commented 6 years ago

Bug report

Steps to reproduce

1.

<NumericInput
  min={1}
  value={this.state.value}
  className="numeric-input"
  onValueChange={this.handleChange}
  clampValueOnBlur={true}
/>
  1. Enter "5----" into the input
  2. Blur

Actual behavior

handleChange is called with 0

Expected behavior

handleChange is not called. I think I also expect the text to reset to the value prop.

cmslewis commented 6 years ago

@rafeememon FWIW this behavior is intended; it's copied from Sketch's numeric input. Open to changing it if it's unintuitive. @llorca what do you think?

rafeememon commented 6 years ago

Cool, I think it's unintuitive to me because I would expect for any value given to onValueChange to be within the min/max I specify so that I don't need to write my own bounds-checking logic.

llorca commented 6 years ago

@cmslewis seems like reasonable request! why it handleChange called with 0? intuitively I'd guess it wouldn't be called, or be called with null

giladgray commented 6 years ago

given the current behavior, i think handleChange should have been called with 1: the minimum.