X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/02109725d788c1092c0b4023cee41ea901ed1a58..b5b75b89e923864389f814af97974a55b69a343f:/src/components/float-input/float-input.tsx

diff --git a/src/components/float-input/float-input.tsx b/src/components/float-input/float-input.tsx
index b032319a..1b909306 100644
--- a/src/components/float-input/float-input.tsx
+++ b/src/components/float-input/float-input.tsx
@@ -2,7 +2,7 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import * as React from 'react';
+import React from 'react';
 import { Input } from '@material-ui/core';
 import { InputProps } from '@material-ui/core/Input';
 
@@ -15,13 +15,17 @@ export class FloatInput extends React.Component<InputProps> {
         const { onChange = () => { return; } } = this.props;
         const [, fraction] = event.target.value.split('.');
         this.setState({ endsWithDecimalSeparator: fraction === '' });
+        const parsedValue = parseFloat(event.target.value).toString();
+        event.target.value = parsedValue;
         onChange(event);
     }
 
     render() {
+        const parsedValue = parseFloat(typeof this.props.value === 'string' ? this.props.value : '');
+        const value = isNaN(parsedValue) ? '' : parsedValue.toString();
         const props = {
             ...this.props,
-            value: this.props.value + (this.state.endsWithDecimalSeparator ? '.' : ''),
+            value: value + (this.state.endsWithDecimalSeparator ? '.' : ''),
             onChange: this.handleChange,
         };
         return <Input {...props} />;
