From 9fb0db19128cfb3ecb7196f925d1e7a9497ed7fa Mon Sep 17 00:00:00 2001 From: ivaosthu Date: Sat, 3 Dec 2016 14:29:33 +0100 Subject: [PATCH] Trim name inputs for feature toggle and strategy. closes #12 --- frontend/src/component/feature/form/index.jsx | 10 +++++++++- frontend/src/component/strategies/add-strategy.jsx | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/frontend/src/component/feature/form/index.jsx b/frontend/src/component/feature/form/index.jsx index 98050c541f..c6de46468b 100644 --- a/frontend/src/component/feature/form/index.jsx +++ b/frontend/src/component/feature/form/index.jsx @@ -4,6 +4,14 @@ import Button from 'react-toolbox/lib/button'; import Switch from 'react-toolbox/lib/switch'; import StrategiesSection from './strategies-section-container'; +const trim = (value) => { + if (value && value.trim) { + return value.trim(); + } else { + return value; + } +}; + class AddFeatureToggleComponent extends Component { componentWillMount () { @@ -46,7 +54,7 @@ class AddFeatureToggleComponent extends Component { value={name} error={nameError} onBlur={(v) => validateName(v)} - onChange={(v) => setValue('name', v)} /> + onChange={(v) => setValue('name', trim(v))} /> { + if (value && value.trim) { + return value.trim(); + } else { + return value; + } +}; + function gerArrayWithEntries (num) { return Array.from(Array(num)); } @@ -33,7 +41,7 @@ const AddStrategy = ({ setValue('name', value)} + onChange={(value) => setValue('name', trim(value))} value={input.name} />