0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 18:32:41 +00:00

add autoSuggest option to filter on chosen attribute

This commit is contained in:
Gazook89
2022-11-24 23:08:41 -06:00
parent fb95039368
commit b54d225f11

View File

@@ -10,11 +10,10 @@ const Combobox = createClass({
return {
trigger : 'hover',
default : '',
// autoSuggest : true,
// clearAutoSuggestOnClick : true
autoSuggest : {
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){
const suggestMethod = this.props.autoSuggest.suggestMethod;
const filterOn = this.props.autoSuggest.filterOn;
dropdownChildren = dropdownChildren.map((item)=>({
...item,
value : item.props['data-value']
value : item.props[filterOn]
}));
if(suggestMethod === 'includes'){
console.log('includes');