🐛 répare le changement de période

pull/542/head
Johan Girod 2019-05-17 17:13:20 +02:00
parent 039d65d818
commit ccb045d161
No known key found for this signature in database
GPG Key ID: 9E27B57DA2E8AE12
2 changed files with 11 additions and 6 deletions

View File

@ -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(

View File

@ -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 (
<li
@ -199,7 +198,6 @@ const Target = ({
/>
)}
<TargetInputOrValue
key={suggestionValue}
{...{
target,
targets,
@ -216,7 +214,6 @@ const Target = ({
suggestions={target.suggestions}
onFirstClick={value => {
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}
/>