From f0722ec06825471094dccde39a50bbc975de30a1 Mon Sep 17 00:00:00 2001 From: Jed Watson Date: Wed, 13 Sep 2017 03:01:55 +1000 Subject: [PATCH] Async shouldn't always clear options on select This behaviour is default now, and implemented in the Select component itself. Use closeOnSelect={false} and onSelectResetsInput={false} to leave the suggestions open. --- HISTORY.md | 1 + src/Async.js | 12 ------------ 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index f740e35329..28b1a1ff08 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -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 diff --git a/src/Async.js b/src/Async.js index af7daed867..3fd85103d5 100644 --- a/src/Async.js +++ b/src/Async.js @@ -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; @@ -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({