Skip to content
This repository has been archived by the owner on Dec 13, 2020. It is now read-only.

Commit

Permalink
Fix lookups in filters #600
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunkat committed May 29, 2017
1 parent bf49f20 commit 604917b
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions src/components/widget/Lookup/RawLookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class RawLookup extends Component {
}

componentDidMount() {
const {selected} = this.props;
const {selected, defaultValue} = this.props;

this.handleValueChanged();

Expand All @@ -38,13 +38,19 @@ class RawLookup extends Component {
}else{
this.handleBlur(this.clearState);
}

if(defaultValue){
this.inputSearch.value =
defaultValue[Object.keys(defaultValue)[0]];
}
}

componentDidUpdate(prevProps) {
this.handleValueChanged();

const {
autoFocus, defaultValue, fireClickOutside, handleInputEmptyStatus
autoFocus, defaultValue, fireClickOutside, handleInputEmptyStatus,
filterWidget
} = this.props;
const {isInputEmpty, shouldBeFocused} = this.state;

Expand All @@ -68,24 +74,34 @@ class RawLookup extends Component {
defaultValue[Object.keys(defaultValue)[0]];
}
}

if(filterWidget && defaultValue === null){
this.inputSearch.value = defaultValue;
}
}

handleSelect = (select) => {
const {
onChange, handleInputEmptyStatus, mainProperty, setNextProperty
onChange, handleInputEmptyStatus, mainProperty, setNextProperty,
filterWidget
} = this.props;

this.setState({
selected: null
}, () => {

if(filterWidget){
onChange(mainProperty[0].parameterName, select);
setNextProperty(mainProperty[0].parameterName);
} else {
onChange(mainProperty[0].field, select);

this.inputSearch.value = select[Object.keys(select)[0]];
handleInputEmptyStatus(false);
setNextProperty(mainProperty[0].field);
}

this.inputSearch.value = select[Object.keys(select)[0]];
handleInputEmptyStatus(false);
this.handleBlur();

this.handleBlur();
});
}

Expand Down

0 comments on commit 604917b

Please sign in to comment.