diff --git a/source/components/Value.js b/source/components/Value.js index a158bdff1..6d21ecdb1 100644 --- a/source/components/Value.js +++ b/source/components/Value.js @@ -80,10 +80,6 @@ export default withLanguage( numberFormatter({ style: 'percent', maximumFractionDigits: 3 })( nodeValue ) - ) : unitText === '(%)' ? ( - numberFormatter({ style: 'percent', maximumFractionDigits: 3 })( - nodeValue / 100 - ) ) : ( <> {numberFormatter({ diff --git a/source/components/conversation/FormDecorator.js b/source/components/conversation/FormDecorator.js index 6afc10a29..87a0555d2 100644 --- a/source/components/conversation/FormDecorator.js +++ b/source/components/conversation/FormDecorator.js @@ -35,12 +35,25 @@ export var FormDecorator = formType => RenderField => helpVisible: false } render() { - let { stepAction, fieldName, inversion, setFormValue } = this.props + let { + stepAction, + fieldName, + inversion, + setFormValue, + unit + } = this.props let submit = cause => stepAction('fold', fieldName, cause), stepProps = { ...this.props, submit, - setFormValue: (value, name = fieldName) => setFormValue(name, value) + setFormValue: (value, name = fieldName) => + setFormValue(name, value), + ...(unit === '%' + ? { + format: x => (x == null ? null : x * 100), + normalize: x => (x == null ? null : x / 100) + } + : {}) } return ( diff --git a/source/components/conversation/Input.js b/source/components/conversation/Input.js index 518535545..be4fd7eb2 100644 --- a/source/components/conversation/Input.js +++ b/source/components/conversation/Input.js @@ -55,7 +55,6 @@ export default compose( /> {suffixed && (