X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/b407fff9a10136ff62e5b3e5bbaa74c8656aaf9d..514574540614593941c39592d9f9972f770e0cb7:/src/components/float-input/float-input.tsx?ds=sidebyside

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} />;
