Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add loading indicator to combo box control author selector #68927

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

adamsilverstein
Copy link
Member

@adamsilverstein adamsilverstein commented Jan 28, 2025

This PR is a rework of the effort in #27865 - see that ticket for additional details.

Testing instructions

  1. Create a large number of editors (see below for command).
  2. Load a page in the editor
  3. Open DevTools and throttle network connections to a 3G speed to slow down the rest API responses
  4. Click the author to edit, then try typing in part of a user name

Expected results:

  • A spinner is shown while the search callback executes
  • the "No items found' string only shows when the search completes (and no items are found)

Helpful wp-cli commands for testing:

Generate many users to test searching: wp user generate --role=editor --count=100
Delete test users: wp user delete $(wp user list --role=editor --field=ID) --reassign=2

@adamsilverstein
Copy link
Member Author

adamsilverstein commented Jan 28, 2025

Note: the drop-down shows "No items found." during the search, a bug clearly visible currently (before this PR) when throttling the search callback.

@Mamaduka Mamaduka added [Type] Enhancement A suggestion for improvement. Needs Design Feedback Needs general design feedback. [Package] Components /packages/components labels Jan 29, 2025
@adamsilverstein adamsilverstein marked this pull request as ready for review January 29, 2025 14:30
@adamsilverstein adamsilverstein requested review from Mamaduka and removed request for ajitbohra January 29, 2025 14:30
Copy link

github-actions bot commented Jan 29, 2025

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: adamsilverstein <[email protected]>
Co-authored-by: Mamaduka <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@adamsilverstein
Copy link
Member Author

I updated the PR to avoid showing "No items found" string while the results are still loading.

@adamsilverstein adamsilverstein changed the title Add loading indicator to author selector Add loading indicator to combo box control author selector Jan 29, 2025
@@ -44,13 +45,14 @@ export default function PostAuthorCombobox() {
<ComboboxControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Author' ) }
label={ __( 'Authorz' ) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ha, this was me trying to get my build working and not seeing changes. will revert!

@@ -157,7 +158,7 @@ export function SuggestionsList<
);
/* eslint-enable jsx-a11y/click-events-have-key-events */
} ) }
{ suggestions.length === 0 && (
{ suggestions.length === 0 && ! isLoading && (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SuggestionsList component is shared, which is why we're passing the isLoading prop, correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right

Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@adamsilverstein
Copy link
Member Author

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.

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.

@Mamaduka
Copy link
Member

I think it's okay to change the SuggestionsList here, but let's avoid adding the isLoading prop to the FormTokenField. This way we can focus only on ComboboxControl improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Design Feedback Needs general design feedback. [Package] Components /packages/components [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants