mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2025-01-10 14:42:13 -05:00
check min too
This commit is contained in:
parent
9eb3b7af39
commit
e39b4edce1
1 changed files with 5 additions and 1 deletions
|
@ -34,9 +34,12 @@ export default function (Input) {
|
|||
const validatesNumeric = isNumeric ? !isNaN(e.target.value) : true;
|
||||
if (e.target.value !== null && validatesNumeric ) {
|
||||
let val = Number(e.target.value);
|
||||
if (typeof this.props.max !== 'undefined' && val > this.props.max) {
|
||||
if (typeof this.props.max !== 'undefined' && val > Number(this.props.max)) {
|
||||
val = this.props.max;
|
||||
}
|
||||
if (typeof this.props.min !== 'undefined' && val < Number(this.props.min)) {
|
||||
val = this.props.min;
|
||||
}
|
||||
this.props.onSubmit(val);
|
||||
}
|
||||
this.setState({value: e.target.value});
|
||||
|
@ -57,6 +60,7 @@ export default function (Input) {
|
|||
|
||||
LiveInput.propTypes = {
|
||||
max: PropTypes.number,
|
||||
min: PropTypes.number,
|
||||
onSubmit: PropTypes.func.isRequired,
|
||||
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue