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

Dropdown options update triggered by onSearchChange #1242

Closed
jhartma opened this issue Jan 28, 2017 · 5 comments
Closed

Dropdown options update triggered by onSearchChange #1242

jhartma opened this issue Jan 28, 2017 · 5 comments

Comments

@jhartma
Copy link

jhartma commented Jan 28, 2017

In my dropdown module, the options consist of a list of users which are fetched remotely and based on the search value of the dropdown.

<Form.Field
  allowAdditions
  control={Dropdown}
  loading={this.props.loading}
  onSearchChange={this.onSearchChange.bind(this)}
  options={this.state.users}
  placeholder="Select user"
  search
  selection
/>

When some characters are rendered in the seach field, the dropdown options should display the fetched results.

Strangely, this works when there is only one result. When there are more, no results are shown. I do see the options correctly shown in as <options> in the <select> node, but the corresponding <DropdownItem> are not rendered. Logging the results in the console also shows them. When I blur the search box and focus it again, the results are all there. So it seems like the dropdown options don't update when there is more than 1 result.

@levithomason
Copy link
Member

This is a use case for the <Search />. However, what you described should work as well.

Please provide a codepen repro and we'll look into it.

@jhartma
Copy link
Author

jhartma commented Jan 29, 2017

I cobbled together a codepen here

And the <Search /> component is great, only that I need the allowAdditions prop which the <Dropdown /> offers

@jhartma
Copy link
Author

jhartma commented Jan 30, 2017

Okay I got it working, I close the issue

@jhartma jhartma closed this as completed Jan 30, 2017
@dackers86
Copy link

dackers86 commented Mar 28, 2017

@jhartma Would it be possible to explain how you fixed your solution?

I am experiencing the same problem, the options will only update after a fetch once the I have clicked off screen...?

  <Dropdown
    allowAdditions
    options={this.state.addressOptions}
    placeholder='Please enter your address'
    search
    selection
    fluid
    onChange={this.handleChange}
    onSearchChange={this.handleSearchChange.bind(this)}
  />

@jhartma
Copy link
Author

jhartma commented Mar 31, 2017

Yep, this works for some reason:

<Form.Field
  allowAdditions
  control={Dropdown}
  disabled={disabled}
  fluid
  id="input-invite-user"
  loading={this.props.loading}
  onAddItem={this.handleAddition}
  onChange={this.handleChange.bind(this)}
  onSearchChange={this.onSearchChange.bind(this)}
  options={users}
  placeholder="Select user"
  search
  selection
  value={value}
  width="7"
 />

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

No branches or pull requests

3 participants