Skip to content

Commit

Permalink
Async shouldn't always clear options on select
Browse files Browse the repository at this point in the history
This behaviour is default now, and implemented in the Select component itself. Use closeOnSelect={false} and onSelectResetsInput={false} to leave the suggestions open.
  • Loading branch information
JedWatson committed Sep 12, 2017
1 parent a13b144 commit f0722ec
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 12 deletions.
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* added; new `closeOnSelect` prop (defaults to `true`) that controls whether the menu is closed when an option is selected, thanks to [Michael Elgar](https://github.com/melgar) for the original idea
* changed; by default, the menu for multi-selects now closes when an option is selected
* changed; `Async` component no longer always clears options when one is selected (although the menu is now closed by default). Use `closeOnSelect={false} onSelectResetsInput={false}` to leave the menu open.
* fixed; `Async` component always called `onChange` even when it wasn't provided
* fixed; input lag for the `Async` component when results are returned from cache
* fixed; required was not being updated without an onChange handler
Expand Down
12 changes: 0 additions & 12 deletions src/Async.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ export default class Async extends Component {
this._callback = null;
}

clearOptions() {
this.setState({ options: [] });
}

loadOptions (inputValue) {
const { loadOptions } = this.props;
const cache = this._cache;
Expand Down Expand Up @@ -186,14 +182,6 @@ export default class Async extends Component {
placeholder: isLoading ? loadingPlaceholder : placeholder,
options: (isLoading && loadingPlaceholder) ? [] : options,
ref: (ref) => (this.select = ref),
onChange: (newValues) => {
if (multi && value && (newValues.length > value.length)) {
this.clearOptions();
}
if (typeof onChange === 'function') {
onChange(newValues);
}
}
};

return children({
Expand Down

0 comments on commit f0722ec

Please sign in to comment.