0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 20:42:43 +00:00

add autoSuggest option based on option 'value'

This commit is contained in:
Gazook89
2022-11-24 19:55:18 -06:00
parent 417f9d7291
commit a9ff1cded7
2 changed files with 13 additions and 5 deletions

View File

@@ -8,8 +8,9 @@ const Combobox = createClass({
displayName : 'Combobox',
getDefaultProps : function() {
return {
trigger : 'hover',
default : ''
trigger : 'hover',
default : '',
autoSuggest : true
};
},
getInitialState : function() {
@@ -46,8 +47,6 @@ const Combobox = createClass({
this.setState({
value : e.target.value
}, ()=>{
// const event = new Event('entry');
// console.log(eevent);
this.props.onEntry(e);
});
},
@@ -68,6 +67,14 @@ const Combobox = createClass({
},
renderDropdown : function(dropdownChildren){
if(!this.state.showDropdown) return null;
console.log(dropdownChildren);
if(this.props.autoSuggest === true){
dropdownChildren = dropdownChildren.map((item)=>({
...item,
value : item.props['data-value']
})).filter((item)=>item.value.includes(this.state.value));
}
return (
<div className='dropdown-options'>
{dropdownChildren}