Bugfix: Handle defaultSearchChange when suggestions contain ‘Nav’ items (#7701)

This commit is contained in:
Sanjay Kumar 2017-09-23 12:51:59 +08:00 committed by 陆离
parent 8b1a4f80a9
commit 1dc4e45bce

View File

@ -80,7 +80,14 @@ export default class Mention extends React.Component<MentionProps, MentionState>
defaultSearchChange(value: String): void {
const searchValue = value.toLowerCase();
const filteredSuggestions = (this.props.suggestions || []).filter(
suggestion => suggestion.toLowerCase().indexOf(searchValue) !== -1,
suggestion => {
if (suggestion.type && suggestion.type === Nav) {
return suggestion.props.value ?
suggestion.props.value.toLowerCase().indexOf(searchValue) !== -1
: true;
}
return suggestion.toLowerCase().indexOf(searchValue) !== -1;
},
);
this.setState({
suggestions: filteredSuggestions,