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

Editor: Add loading state to the 'PostAuthorCombobox' component #68991

Conversation

adamsilverstein
Copy link
Member

@adamsilverstein adamsilverstein commented Jan 31, 2025

What?

Add a loading indicator to the author dropdown. Fix a bug where it was impossible to tell a search was occuring, leating to poor UX especially over slower connections.

Follow up to #68990

Post author part of #68927

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

Screencasts

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

Copy link

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 <adamsilverstein@git.wordpress.org>

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

@adamsilverstein adamsilverstein added [Type] Bug An existing feature does not function as intended Needs Design Feedback Needs general design feedback. [Package] Components /packages/components labels Jan 31, 2025
@Mamaduka Mamaduka changed the title Add/combobox loading spinner author part Editor: Add loading state to the 'PostAuthorCombobox' component Feb 4, 2025
@Mamaduka Mamaduka added [Package] Editor /packages/editor [Type] Enhancement A suggestion for improvement. and removed Needs Design Feedback Needs general design feedback. [Package] Components /packages/components [Type] Bug An existing feature does not function as intended labels Feb 4, 2025
@@ -30,6 +30,7 @@ export function useAuthorsQuery( search ) {
authorId: _authorId,
authors: getUsers( query ),
postAuthor: getUser( _authorId, BASE_QUERY ),
isLoading: isResolving( 'getUsers', [ query ] ),
Copy link
Member

Choose a reason for hiding this comment

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

Question (non-blocking): Should we track the loading state for every query or just for the search?

Copy link
Member Author

@adamsilverstein adamsilverstein Feb 5, 2025

Choose a reason for hiding this comment

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

Good question, my assumption was that search was the only async query, are there others?

If we did expand this to all queries, what would that look like? Does the isResolving call change?

Copy link
Member

Choose a reason for hiding this comment

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

The initial query is also async, but I guess the loading state could also be a helpful hint.

Looks good to ship as it is ✅

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.

This should be good to merge after #68990.

Left one question, but it's not a blocker.

@adamsilverstein adamsilverstein merged commit e850c68 into WordPress:trunk Feb 6, 2025
84 of 85 checks passed
@github-actions github-actions bot added this to the Gutenberg 20.3 milestone Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Editor /packages/editor [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants