Skip to content

Commit

Permalink
AutocompleteSelectEdit - Fixing merge issue + changing _setValue func…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
Hartorn authored and c3dr0x committed Nov 4, 2017
1 parent f055f52 commit 9128e3d
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/components/input/autocomplete-select/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,19 @@ class AutocompleteSelectEdit extends Component {
const { value, inputTimeout } = this.props;

if (value !== undefined && value !== null) {
this._setValue(value);
this._setValue(this.props);
}

document.addEventListener('click', this._handleDocumentClick);
this._debouncedQuerySearcher = debounce(this._querySearcher, inputTimeout);
}

/** @inheritdoc */
componentWillReceiveProps({ value, customError, error, keyResolver }) {
componentWillReceiveProps(nextProps) {
const { value, customError, error, labelName, wholeItem } = nextProps;
if (value !== this.props.value && value !== undefined && value !== null) { // value is defined, call the keyResolver to get the associated label
const inputValue = wholeItem ? value[labelName] : value;
this.setState({ inputValue, customError }, () => this._setValue(value));
this.setState({ inputValue, customError }, () => this._setValue(nextProps));
} else if (customError !== this.props.customError) {
this.setState({ customError });
}
Expand Down Expand Up @@ -129,12 +130,14 @@ class AutocompleteSelectEdit extends Component {
document.removeEventListener('click', this._handleDocumentClick);
}


/**
* Set value.
* @param {object|string} value Value.
*
* @param {object} object containing props
* @memberof AutocompleteSelectEdit
*/
_setValue(value) {
const { keyResolver, labelName, wholeItem } = this.props;
_setValue({ value, keyResolver, labelName, wholeItem }) {

if (wholeItem) {
this.setState({ inputValue: value[labelName], fromKeyResolver: true });
Expand Down

0 comments on commit 9128e3d

Please sign in to comment.