From 45be8b4969ab74aba1e886f16c6092f7dea16797 Mon Sep 17 00:00:00 2001 From: Daniel Heath Date: Thu, 6 Oct 2016 16:49:01 +1100 Subject: [PATCH] Only remove options if a loading placeholder is available Currently, when `isLoading` is set to true, the options array is set to an empty array and we show the loading placeholder instead. Our app has an async service which responds in a couple of ms, resulting in the autocomplete list flickering in and out of existence as you type. This change allows users to opt out of the 'clear options while loading' behavior by not providing a loading placeholder. --- src/Async.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Async.js b/src/Async.js index 43b78ce305..b28aaadac0 100644 --- a/src/Async.js +++ b/src/Async.js @@ -8,7 +8,7 @@ const propTypes = { children: React.PropTypes.func.isRequired, // Child function responsible for creating the inner Select component; (props: Object): PropTypes.element ignoreAccents: React.PropTypes.bool, // strip diacritics when filtering; defaults to true ignoreCase: React.PropTypes.bool, // perform case-insensitive filtering; defaults to true - loadingPlaceholder: React.PropTypes.oneOfType([ // replaces the placeholder while options are loading + loadingPlaceholder: React.PropTypes.oneOfType([ // replaces the placeholder while options are loading React.PropTypes.string, React.PropTypes.node ]), @@ -146,7 +146,7 @@ export default class Async extends Component { const props = { noResultsText: isLoading ? loadingPlaceholder : searchPromptText, placeholder: isLoading ? loadingPlaceholder : placeholder, - options: isLoading ? [] : options, + options: (isLoading && loadingPlaceholder) ? [] : options, ref: (ref) => (this.select = ref) };