React-autosuggest: Force open suggestions on focus (even without suggestions)

Created on 6 Mar 2017  路  3Comments  路  Source: moroshko/react-autosuggest

In my app, I use renderSuggestionsContainer to add some custom action buttons right after the suggestions. I need those actions to be available from the moment the user focus on the input, even before typing anything. Is there a proper way of achieving this?

Thanks.

Most helpful comment

autosuggest-arrow

We have the same options to open autosuggest on outside event (clicking on arrow)

    if (!this.autosuggest.state.isCollapsed) {
      console.log('Before close onClick')
      this.autosuggest.setState({ isCollapsed: true })
    } else {
      console.log('Before open onClick')
      this.autosuggest.setState({ isCollapsed: false })
    }

But this scenario does not work. It will open suggestions only when click event is originated from autosuggest's input field.

I think we really need this.autosuggest.open() and this.autosuggest.close() methods.

All 3 comments

Interesting scenario!

I can't see an easy way to achieve this with the current API.
Here is an attempt to achieve something that looks similar.

If you have any ideas how to extend the API to support this scenario, please share.

autosuggest-arrow

We have the same options to open autosuggest on outside event (clicking on arrow)

    if (!this.autosuggest.state.isCollapsed) {
      console.log('Before close onClick')
      this.autosuggest.setState({ isCollapsed: true })
    } else {
      console.log('Before open onClick')
      this.autosuggest.setState({ isCollapsed: false })
    }

But this scenario does not work. It will open suggestions only when click event is originated from autosuggest's input field.

I think we really need this.autosuggest.open() and this.autosuggest.close() methods.

It's also might be a trigger mode when suggestion list should be opened on click(touch) event and closed on next click, working like a trigger. No matter whether empty input or not.

Was this page helpful?
0 / 5 - 0 ratings