Add loading indicator to combo box control author selector#68927
Add loading indicator to combo box control author selector#68927adamsilverstein wants to merge 10 commits into
Conversation
|
Note: the drop-down shows "No items found." during the search, a bug clearly visible currently (before this PR) when throttling the search callback. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
I updated the PR to avoid showing "No items found" string while the results are still loading. |
| __nextHasNoMarginBottom | ||
| __next40pxDefaultSize | ||
| label={ __( 'Author' ) } | ||
| label={ __( 'Authorz' ) } |
There was a problem hiding this comment.
ha, this was me trying to get my build working and not seeing changes. will revert!
| /* eslint-enable jsx-a11y/click-events-have-key-events */ | ||
| } ) } | ||
| { suggestions.length === 0 && ( | ||
| { suggestions.length === 0 && ! isLoading && ( |
There was a problem hiding this comment.
The SuggestionsList component is shared, which is why we're passing the isLoading prop, correct?
Mamaduka
left a comment
There was a problem hiding this comment.
Thanks, @adamsilverstein!
My suggestion is to limit new loading state changes to the ComboboxControl. The FormTokenField component is a bit tricky, as input and tokens can wrap on multiple lines. So, I'm not sure if the spinner suffix design will work for it.
Do you mind including a screenshot or screencast in the PR description?
Hopefully, the v2 design will account for the loading state of #64086.
cc @WordPress/gutenberg-components
Thanks for the review. I will add some screenshots/screencasts to show what this change does (when I am back at my desk Friday). I can also take a look at other consumers of the component to make sure they are unaffected. The main goal of the change here is to avoid showing "No items found" string while the (author) search is underway. Since it isn't directly related to adding a spinner, I can break it out into a follow up PR and we can explore the issue separately. |
|
I think it's okay to change the |
ciampo
left a comment
There was a problem hiding this comment.
Finally, I would also suggest
| onChange={ handleSelect } | ||
| allowReset={ false } | ||
| hideLabelFromVision | ||
| isLoading={ isLoading } |
There was a problem hiding this comment.
My preference would we to focus this PR solely on the ComboboxControl component.
We should add a Storybook example here to allow for easy testing of the component in isolation.
In a separate, follow-up PR, we could then tweak the post author combobox to use the new prop
There was a problem hiding this comment.
The entire point of this PR is to improve the author selector - changing only the combobox won't actually change anything, shouldn't we aim for PRs that actually improve things?
I can look into adding to the storybook, would this just be a variation with the isLoading prop?
There was a problem hiding this comment.
The @wordpress/component package is not only used in the Gutenberg repository, but it's also used by third-party developers. Therefore, we usually try to keep changes to the "library" separate from changes to the Gutenberg app (hence why I suggest testing the changes in isolation in Storybook).
Having smaller and more focused PRs is also easier to review, and understand for a future developer stumbling upon it.
There was a problem hiding this comment.
Having smaller and more focused PRs is also easier to review, and understand for a future developer stumbling upon it.
I understand the principal, however this entire PR is currently less than 35 lines modified so I think is already easy to review and understand! Given the testing instructions I provided, I feel having the PR do something makes it easier to test and understand.
That said, I sense that you feel strongly about this and I will defer to your more recent experience building here. I will split the combobox and author changes into separate PRs.
| help, | ||
| allowReset = true, | ||
| className, | ||
| isLoading = false, |
There was a problem hiding this comment.
Adding this prop won't affect existing usages, although I wonder if it's a good idea, API-wise.
The component doesn't have a canonical example of how to use it with asynchronously loaded options, and I wonder if adding this prop will improve the DevX (related to #55574) — @WordPress/gutenberg-components what do you think?
If we want to encourage this pattern, we should at least add a Storybook example about it?
There was a problem hiding this comment.
I wonder if adding this prop will improve the DevX
Not sure about DevX, this change is about improving User Experience. As is, the combobox selector provides a poor UX when the internet connection is slow or unreliable. The user has no way of knowing that a search is underway during the async search. This shortcoming was overlooked when we originally built the component and I feel this more of a bug than an enhancement.
I will remove these changes for now and we can consider adding them in a follow up PR. I have included screencasts above so you can see why I added this change in the first place. |
Co-authored-by: Marco Ciampini <marco.ciampo@gmail.com>
This reverts commit 76488c1.
Reverted in fd97afc |
| - Default: `true` | ||
|
|
||
| ### placeholder | ||
| #### placeholder |
|
|
||
| #### isLoading | ||
|
|
||
| If true, the dropdown will show a loading indicator. |
There was a problem hiding this comment.
Let's match the same description as the one from types.ts
This PR is a rework of the effort in #27865 - see that ticket for additional details.
Testing instructions
Expected results:
Helpful wp-cli commands for testing:
Generate many users to test searching:
wp user generate --role=editor --count=100Delete test users:
wp user delete $(wp user list --role=editor --field=ID) --reassign=2Screencasts
Before changes (trunk)
before2.mp4
Add spinner
(note message "No items found" shows during search callback)
spinner-only.mp4
Final PR
(including removal of "No items found" during load)
after.mp4