From e39b4edce1f09bc557f4a2472df52b25b41e3ca0 Mon Sep 17 00:00:00 2001 From: Matthew Taylor Date: Fri, 3 Nov 2017 12:49:34 -0400 Subject: [PATCH] check min too --- src/components/forms/live-input-hoc.jsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/forms/live-input-hoc.jsx b/src/components/forms/live-input-hoc.jsx index 812f3ed5..30792962 100644 --- a/src/components/forms/live-input-hoc.jsx +++ b/src/components/forms/live-input-hoc.jsx @@ -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]) };