mirror of
https://github.com/Sonarr/Sonarr
synced 2024-12-25 09:18:34 +00:00
Fixed: Error when editing torrent indexer
This commit is contained in:
parent
223209e1eb
commit
9b212d11f0
1 changed files with 12 additions and 7 deletions
|
@ -9,7 +9,7 @@ function parseValue(props, value) {
|
|||
max
|
||||
} = props;
|
||||
|
||||
if (value == null) {
|
||||
if (value == null || value === '') {
|
||||
return min;
|
||||
}
|
||||
|
||||
|
@ -33,14 +33,18 @@ class NumberInput extends Component {
|
|||
super(props, context);
|
||||
|
||||
this.state = {
|
||||
value: props.value.toString(),
|
||||
value: props.value == null ? '' : props.value.toString(),
|
||||
isFocused: false
|
||||
};
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps, prevState) {
|
||||
if (this.props.value !== prevProps.value && !this.state.isFocused) {
|
||||
this.setState({ value: this.props.value.toString() });
|
||||
const { value } = this.props;
|
||||
|
||||
if (value !== prevProps.value && !this.state.isFocused) {
|
||||
this.setState({
|
||||
value: value == null ? '' : value.toString()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,19 +73,20 @@ class NumberInput extends Component {
|
|||
|
||||
const { value } = this.state;
|
||||
const parsedValue = parseValue(this.props, value);
|
||||
const stringValue = parsedValue == null ? '' : parsedValue.toString();
|
||||
|
||||
if (parsedValue.toString() === value) {
|
||||
if (stringValue === value) {
|
||||
this.setState({ isFocused: false });
|
||||
} else {
|
||||
this.setState({
|
||||
value: parsedValue.toString(),
|
||||
value: stringValue,
|
||||
isFocused: false
|
||||
});
|
||||
}
|
||||
|
||||
onChange({
|
||||
name,
|
||||
value: parseValue(this.props, this.state.value)
|
||||
value: parsedValue
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue