From 0c2d7ec23ec72952b490221c9552d140c86e08a7 Mon Sep 17 00:00:00 2001 From: Connor Silkworth Date: Mon, 22 Jul 2019 16:03:51 -0600 Subject: [PATCH 1/2] Manually set 'isLoading' state for async selects Fixes #2986 --- packages/react-select/src/Async.js | 6 ++++-- .../src/__tests__/__snapshots__/Async.test.js.snap | 1 + .../src/__tests__/__snapshots__/AsyncCreatable.test.js.snap | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/react-select/src/Async.js b/packages/react-select/src/Async.js index c10bc6aacd..b95f7658ad 100644 --- a/packages/react-select/src/Async.js +++ b/packages/react-select/src/Async.js @@ -23,6 +23,7 @@ export type AsyncProps = { cacheOptions: any, onInputChange: (string, InputActionMeta) => void, inputValue?: string, + isLoading: boolean }; export type Props = SelectProps & AsyncProps; @@ -31,6 +32,7 @@ export const defaultProps = { cacheOptions: false, defaultOptions: false, filterOption: null, + isLoading: false }; type State = { @@ -158,7 +160,7 @@ export const makeAsyncSelect = ( return inputValue; }; render() { - const { loadOptions, ...props } = this.props; + const { loadOptions, isLoading: isLoadingProp, ...props } = this.props; const { defaultOptions, inputValue, @@ -179,7 +181,7 @@ export const makeAsyncSelect = ( this.select = ref; }} options={options} - isLoading={isLoading} + isLoading={isLoading || isLoadingProp} onInputChange={this.handleInputChange} /> ); diff --git a/packages/react-select/src/__tests__/__snapshots__/Async.test.js.snap b/packages/react-select/src/__tests__/__snapshots__/Async.test.js.snap index 1c0d50ebf2..291e102f20 100644 --- a/packages/react-select/src/__tests__/__snapshots__/Async.test.js.snap +++ b/packages/react-select/src/__tests__/__snapshots__/Async.test.js.snap @@ -140,6 +140,7 @@ exports[`defaults - snapshot 1`] = ` cacheOptions={false} defaultOptions={false} filterOption={null} + isLoading={false} > Date: Wed, 2 Oct 2019 17:18:15 +1000 Subject: [PATCH 2/2] Adding changeset --- .changeset/nine-goats-care.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/nine-goats-care.md diff --git a/.changeset/nine-goats-care.md b/.changeset/nine-goats-care.md new file mode 100644 index 0000000000..ead4342084 --- /dev/null +++ b/.changeset/nine-goats-care.md @@ -0,0 +1,5 @@ +--- +"react-select": minor +--- + +Add `isLoading` prop support to the AsyncSelect component (see #3690)