From ccb045d161ef07a72e117ae8140a461ceda62ea9 Mon Sep 17 00:00:00 2001 From: Johan Girod Date: Fri, 17 May 2019 17:13:20 +0200 Subject: [PATCH] =?UTF-8?q?:bug:=20r=C3=A9pare=20le=20changement=20de=20p?= =?UTF-8?q?=C3=A9riode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/components/CurrencyInput/CurrencyInput.js | 10 +++++++++- source/components/TargetSelection.js | 7 ++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/source/components/CurrencyInput/CurrencyInput.js b/source/components/CurrencyInput/CurrencyInput.js index 36b216a0f..2f0374287 100644 --- a/source/components/CurrencyInput/CurrencyInput.js +++ b/source/components/CurrencyInput/CurrencyInput.js @@ -14,7 +14,7 @@ let isCurrencyPrefixed = language => class CurrencyInput extends Component { state = { - value: this.props.defaultValue + value: this.props.storeValue } onChange = this.props.debounce ? debounce(this.props.debounce, this.props.onChange) @@ -39,6 +39,14 @@ class CurrencyInput extends Component { } this.onChange(event) } + componentDidUpdate(prevProps) { + if ( + prevProps.storeValue !== this.props.storeValue && + this.props.storeValue !== this.state.value + ) { + this.setState({ value: this.props.storeValue }) + } + } render() { let forwardedProps = omit( diff --git a/source/components/TargetSelection.js b/source/components/TargetSelection.js index b4c7ec863..384f21b9e 100644 --- a/source/components/TargetSelection.js +++ b/source/components/TargetSelection.js @@ -7,7 +7,7 @@ import withLanguage from 'Components/utils/withLanguage' import withSitePaths from 'Components/utils/withSitePaths' import { encodeRuleName } from 'Engine/rules' import { compose, isEmpty, isNil, propEq } from 'ramda' -import React, { Component, PureComponent, useState } from 'react' +import React, { Component, PureComponent } from 'react' import { withTranslation } from 'react-i18next' import { connect } from 'react-redux' import { Link } from 'react-router-dom' @@ -173,7 +173,6 @@ const Target = ({ }) => { const isSmallTarget = !target.question || !target.formule || isEmpty(target.formule) - const [suggestionValue, setSuggestionValue] = useState(null) return (
  • )} { setFormValue(target.dottedName, '' + value) - setSuggestionValue(value) }} rulePeriod={target.pĂ©riode} colouredBackground={true} @@ -253,7 +250,7 @@ let CurrencyField = withColours(props => { }} debounce={600} className="targetInput" - defaultValue={props.input.value} + storeValue={props.input.value} {...props.input} {...props} />