Removes number conversion for dirty input (#878)

Fixes #870

- #870

This regression bug was introduced as part of the refactoring of
typescript.
Here:
- #848

I've added tests to cover the scenario so that it won't happen again,
hopefully.
This commit is contained in:
Harel M
2024-02-07 10:32:19 +02:00
committed by GitHub
parent c84c7a7b96
commit bc5ecfade6
3 changed files with 26 additions and 3 deletions

View File

@@ -19,7 +19,10 @@ type InputNumberState = {
editing: boolean
editingRange?: boolean
value?: number
dirtyValue?: number
/**
* This is the value that is currently being edited. It can be an invalid value.
*/
dirtyValue?: number | string | undefined
}
export default class InputNumber extends React.Component<InputNumberProps, InputNumberState> {
@@ -66,7 +69,7 @@ export default class InputNumber extends React.Component<InputNumberProps, Input
}
this.setState({
dirtyValue: newValue === "" ? undefined : value,
dirtyValue: newValue === "" ? undefined : newValue,
})
}
@@ -125,7 +128,7 @@ export default class InputNumber extends React.Component<InputNumberProps, Input
// for example we might go from 13 to 13.23, however because we know
// that came from a keyboard event we always want to increase by a
// single step value.
if (value < this.state.dirtyValue!) {
if (value < +this.state.dirtyValue!) {
value = this.state.value! - step;
}
else {