mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-18 21:34:28 -04:00
@@ -8,12 +8,23 @@ class NumberInput extends Component {
|
||||
// Listeners
|
||||
|
||||
onChange = ({ name, value }) => {
|
||||
const {
|
||||
min,
|
||||
max
|
||||
} = this.props;
|
||||
|
||||
let newValue = null;
|
||||
|
||||
if (value) {
|
||||
newValue = this.props.isFloat ? parseFloat(value) : parseInt(value);
|
||||
}
|
||||
|
||||
if (min != null && newValue < min) {
|
||||
newValue = min;
|
||||
} else if (max != null && newValue > max) {
|
||||
newValue = max;
|
||||
}
|
||||
|
||||
this.props.onChange({
|
||||
name,
|
||||
value: newValue
|
||||
@@ -40,6 +51,8 @@ class NumberInput extends Component {
|
||||
|
||||
NumberInput.propTypes = {
|
||||
value: PropTypes.number,
|
||||
min: PropTypes.number,
|
||||
max: PropTypes.number,
|
||||
isFloat: PropTypes.bool.isRequired,
|
||||
onChange: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user