Select: Unable to leave loading state without re-render?
Summary of the bug
Discovered whileintroducing Playground to ic-select
It seems that the loadingHandler function doesn't consider the loading prop changing to false
@Watch("loading")
loadingHandler(newValue: boolean): void {
newValue && this.triggerLoading();
}
Additionally, updating the loadingLabel prop doesn't change the loading text until loading is toggled off and back on.
🪜 How to reproduce
Tell us the steps to reproduce the problem:
- Go to the React Playground storybook in Select (single)
- click to expand the Select
- in the controls, toggle 'loading' to true
- you'll see the select switch to a loading state
- Toggle 'loading' to false
- The select won't show results, it remains loading. You'll find that expanding and collapsing the select doesn't fix it
📸 Screenshots or code
🧐 Expected behaviour
Switching loading to false should show results / no results. Also, in the Playgrounds (single/searchable select in React, multi-select in Canary) the loadingLabel should update loading text whenever the prop is changed
This also applies to Multi-Select. After selecting multiple options & then setting loading to true the field contains 1 or more commas
then setting to false the loading state does not clear
If only a single value is selected & then loading is set to true, the placeholder text is black (should be grey)
bad:
good:
may want to consider leaving this until after #2108 is complete
Summary of select/loading bugs following testing in Stackblitz and Storybook playground
| Select | Searchable select | Multi-select | |
|---|---|---|---|
| Toggling loading prop to false doesn't show results | Present in storybook | Present in storybook | Present in storybook |
| "Clear selection" button next to placeholder text if loading is changed to true while value is selected | Present in storybook and stackblitz | Not present | Present in storybook and stackblitz |
| Placeholder text is wrong colour if loading is changed to true while value is selected | Not present | Not present | Present in storybook and stackblitz |
| Multiple selected values display as commas if loading is changed to true | N/A | N/A | Present in stackblitz | User can use keyboard to select "loading" and "no results found" | Present in stackblitz | Present in stackblitz | Present in stackblitz | User can use search against current options in loading state | N/A | Present in storybook and stackblitz | N/A |