mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-03 08:22:42 +00:00
add autoSuggest option to filter on chosen attribute
This commit is contained in:
@@ -10,11 +10,10 @@ const Combobox = createClass({
|
|||||||
return {
|
return {
|
||||||
trigger : 'hover',
|
trigger : 'hover',
|
||||||
default : '',
|
default : '',
|
||||||
// autoSuggest : true,
|
|
||||||
// clearAutoSuggestOnClick : true
|
|
||||||
autoSuggest : {
|
autoSuggest : {
|
||||||
clearAutoSuggestOnClick : true,
|
clearAutoSuggestOnClick : true,
|
||||||
suggestMethod : 'includes'
|
suggestMethod : 'includes',
|
||||||
|
filterOn : 'data-value' // should allow as array to filter on multiple attributes, or even custom filter
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -78,9 +77,10 @@ const Combobox = createClass({
|
|||||||
|
|
||||||
if(this.props.autoSuggest && !this.state.inputFocused){
|
if(this.props.autoSuggest && !this.state.inputFocused){
|
||||||
const suggestMethod = this.props.autoSuggest.suggestMethod;
|
const suggestMethod = this.props.autoSuggest.suggestMethod;
|
||||||
|
const filterOn = this.props.autoSuggest.filterOn;
|
||||||
dropdownChildren = dropdownChildren.map((item)=>({
|
dropdownChildren = dropdownChildren.map((item)=>({
|
||||||
...item,
|
...item,
|
||||||
value : item.props['data-value']
|
value : item.props[filterOn]
|
||||||
}));
|
}));
|
||||||
if(suggestMethod === 'includes'){
|
if(suggestMethod === 'includes'){
|
||||||
console.log('includes');
|
console.log('includes');
|
||||||
|
|||||||
Reference in New Issue
Block a user