react-autosuggest
react-autosuggest copied to clipboard
Sections with no suggestions are still rendered
The README states:
Note: Sections with no suggestions are not rendered.
However, sections with no suggestions are still rendered. This is clear here. The correct behavior should be to not render anything for a section without items.
I've also encountered the same problem
first thing to come to me to fix it would be to check the length of this.sectionsItems[sectionIndex] and if it's not larger than 0 return false; (or smaller than 1)
Also having the same problem - anyone got a workaround?
@ErisDS This is the workaround I'm using:
renderSuggestionsContainer({ containerProps, children, query }) {
// we need to do this because of https://github.com/moroshko/react-autosuggest/issues/570
const filteredChildren = children && children.filter(child => {
const [ title, items ] = child.props.children
return title.props.section.hits.length
})
return (
<div {... containerProps}>
{filteredChildren}
</div>
)
}