mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-22 13:37:58 +01:00
Only change value of form onblur
This commit is contained in:
parent
d341cc28c9
commit
c149667409
@ -68,10 +68,15 @@ const _NumberField = ({ name, min, max, muiTheme: { palette }, ...props }, conte
|
|||||||
value={_.get(context, name.toString())}
|
value={_.get(context, name.toString())}
|
||||||
onChange={(event, value) => {
|
onChange={(event, value) => {
|
||||||
value = parseFloat(value);
|
value = parseFloat(value);
|
||||||
if (typeof min === 'number') value = Math.max(value, min);
|
|
||||||
if (typeof max === 'number') value = Math.min(value, max);
|
|
||||||
context.onChange(name, value);
|
context.onChange(name, value);
|
||||||
}}
|
}}
|
||||||
|
onBlur={() => {
|
||||||
|
const value = _.get(context, name.toString());
|
||||||
|
let newValue = value;
|
||||||
|
if (typeof min === 'number') newValue = Math.max(newValue, min);
|
||||||
|
if (typeof max === 'number') newValue = Math.min(newValue, max);
|
||||||
|
if (newValue !== value) context.onChange(name, newValue);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
_NumberField.contextTypes = contextTypes;
|
_NumberField.contextTypes = contextTypes;
|
||||||
|
Loading…
Reference in New Issue
Block a user