diff --git a/source/components/TargetSelection.js b/source/components/TargetSelection.js index 12127e22a..a0fd86210 100644 --- a/source/components/TargetSelection.js +++ b/source/components/TargetSelection.js @@ -5,7 +5,7 @@ import { rules, findRuleByName } from 'Engine/rules' import { propEq, contains, without, curry, append, ifElse } from 'ramda' import './TargetSelection.css' import BlueButton from './BlueButton' -import { Field, reduxForm, formValueSelector } from 'redux-form' +import { Field, reduxForm, formValueSelector, change } from 'redux-form' import { connect } from 'react-redux' import { RuleValue } from './rule/RuleValueVignette' import classNames from 'classnames' @@ -26,6 +26,7 @@ export let popularTargetNames = [...salaries, 'aides employeur'] conversationTargetNames: state.conversationTargetNames }), dispatch => ({ + clearFormValue: field => dispatch(change('conversation', field, '')), setConversationTargets: (targetNames, fromScratch = false) => dispatch({ type: 'SET_CONVERSATION_TARGETS', targetNames, fromScratch }) }) @@ -143,13 +144,15 @@ export default class TargetSelection extends Component { } {s.title || s.name} - this.setState({ activeInput: name }) + setActiveInput: name => + this.setState({ activeInput: name }), + clearFormValue: this.props.clearFormValue }} /> @@ -168,12 +171,13 @@ let InputComponent = ({ input, meta: { dirty, error } }) => ( ) -let TargetOrInputValue = ({ +let TargetInputOrValue = ({ s, targets, firstEstimationComplete, activeInput, - setActiveInput + setActiveInput, + clearFormValue }) => ( {activeInput === s.dottedName ? ( @@ -191,7 +195,9 @@ let TargetOrInputValue = ({ attractClick: s.question && targets.length === 0 })} onClick={() => { - s.question && setActiveInput(s.dottedName) + if (!s.question) return + activeInput && clearFormValue(activeInput) + setActiveInput(s.dottedName) }} > {do { @@ -205,6 +211,3 @@ let TargetOrInputValue = ({ {(firstEstimationComplete || s.question) && } ) - -/* - */