Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sections with no suggestions are still rendered #570

Open
gzzo opened this issue Sep 11, 2018 · 3 comments
Open

Sections with no suggestions are still rendered #570

gzzo opened this issue Sep 11, 2018 · 3 comments

Comments

@gzzo
Copy link

gzzo commented Sep 11, 2018

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.

@gijsbotje
Copy link

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)

@ErisDS
Copy link

ErisDS commented Oct 18, 2018

Also having the same problem - anyone got a workaround?

@gzzo
Copy link
Author

gzzo commented Oct 19, 2018

@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>
    )
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants