0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-03 04:02:44 +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 { 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');