X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/424f5418a6fd9f49baa1cc79bf0b51f9ab65ac58..c26c98ff85da6a9ed2b946eae1d3484a3056bd10:/src/views/run-process-panel/inputs/float-input.tsx

diff --git a/src/views/run-process-panel/inputs/float-input.tsx b/src/views/run-process-panel/inputs/float-input.tsx
index aeaf6cdd..56a58012 100644
--- a/src/views/run-process-panel/inputs/float-input.tsx
+++ b/src/views/run-process-panel/inputs/float-input.tsx
@@ -6,9 +6,8 @@ import * as React from 'react';
 import { FloatCommandInputParameter, isRequiredInput } from '~/models/workflow';
 import { Field } from 'redux-form';
 import { isNumber } from '~/validators/is-number';
-import { GenericInput } from '~/views/run-process-panel/inputs/generic-input';
-import { Input as MaterialInput } from '@material-ui/core';
-import { GenericInputProps } from './generic-input';
+import { GenericInputProps, GenericInput } from './generic-input';
+import { FloatInput as FloatInputComponent } from '~/components/float-input/float-input';
 export interface FloatInputProps {
     input: FloatCommandInputParameter;
 }
@@ -16,7 +15,7 @@ export const FloatInput = ({ input }: FloatInputProps) =>
     <Field
         name={input.id}
         commandInput={input}
-        component={FloatInputComponent}
+        component={Input}
         parse={parseFloat}
         format={value => isNaN(value) ? '' : JSON.stringify(value)}
         validate={[
@@ -24,31 +23,15 @@ export const FloatInput = ({ input }: FloatInputProps) =>
                 ? isNumber
                 : () => undefined,]} />;
 
-class FloatInputComponent extends React.Component<GenericInputProps> {
-    state = {
-        endsWithDecimalSeparator: false,
-    };
-
-    handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
-        const [base, fraction] = event.target.value.split('.');
-        this.setState({ endsWithDecimalSeparator: fraction === '' });
-        this.props.input.onChange(event);
-    }
+const Input = (props: GenericInputProps) =>
+    <GenericInput
+        component={InputComponent}
+        {...props} />;
 
-    render() {
-        const props = {
-            ...this.props,
-            input: {
-                ...this.props.input,
-                value: this.props.input.value + (this.state.endsWithDecimalSeparator ? '.' : ''),
-                onChange: this.handleChange,
-            },
-        };
-        return <GenericInput
-            component={Input}
-            {...props} />;
-    }
-}
+const InputComponent = ({ input, meta, commandInput }: GenericInputProps) =>
+    <FloatInputComponent
+        fullWidth
+        error={meta.touched && !!meta.error}
+        disabled={commandInput.disabled}
+        {...input} />;
 
-const Input = (props: GenericInputProps) =>
-    <MaterialInput fullWidth {...props.input} error={props.meta.touched && !!props.meta.error} />;
