react-bootstrap-typeahead icon indicating copy to clipboard operation
react-bootstrap-typeahead copied to clipboard

Add checkboxes in menu items and use the menu as dropdown with async options

Open sukhminderx opened this issue 6 years ago • 4 comments

Version

Steps to reproduce

  1. I used renderMenuItemChildren to achieve this.
  2. on click of the custom menu item, the menu closes and select the clicked item I used the below code to mimic this behavior without need for checkboxes. So that the menu remains open while selection until it is blurred.
<AsyncTypeahead
                {...this.state}
                minLength={1}
                onSearch={this.handleSearch}
                multiple={true}
                placeholder="Enter..."
                open={this.state.open}
                onFocus= {e=>this.setState({open: true})}
                onBlur= {e=>this.setState({open: false})}
                // renderMenuItemChildren={this.renderMenuItemChildren}
                onChange={this.selectionChanged}


Here, the menu remains opened but the issue is the options are cleared and there is no menu item that remains.

Expected Behavior

  1. The checkbox should select the click item but the menu should not close.
  2. As the AsyncTypeahead is used here, the options should not get reset and there should not be a need to again make the API call for data.

Actual Behavior

sukhminderx avatar Dec 12 '19 11:12 sukhminderx

Hi @sukhminderx, thanks for opening this issue. It sounds like you're trying to achieve a combobox behavior. You can use filterBy to control which options get filtered out; see this StackOverflow answer for more details on how to do that.

ericgio avatar Dec 12 '19 18:12 ericgio

@ericgio , I added the filterBy exactly as mentioned in the link. But it does not get called. The version that I am using is: 3.4.5 What am I missing?

sukhminderx avatar Dec 13 '19 09:12 sukhminderx

I'm not sure; It's hard to help you without seeing your code. Did you see the updated answer for versions > 3.0?

ericgio avatar Dec 13 '19 21:12 ericgio

No response, closing.

ericgio avatar Jan 15 '20 19:01 ericgio