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

ComboboxControl: Add an isLoading prop to show a loading spinner #68990

Conversation

adamsilverstein
Copy link
Member

@adamsilverstein adamsilverstein commented Jan 31, 2025

What?

Add a loading indicator to the ComboboxControl component.

ComboboxControl only part of #68927

Copy link

github-actions bot commented Jan 31, 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.

@@ -124,6 +124,7 @@ WithCustomRenderItem.args = {
</div>
);
},
isLoading: true,
Copy link
Member Author

@adamsilverstein adamsilverstein Jan 31, 2025

Choose a reason for hiding this comment

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

@ciampo I added this property, is that right? I was expecting a change when I ran npm run storybook:build but there were none. Do I need to so something else to regenerate storybook assets?

Copy link
Member

Choose a reason for hiding this comment

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

I think we can remove this. People can use controls in the storybook to toggle the value.

Screenshot

CleanShot 2025-02-03 at 20 14 06

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we can remove this. People can use controls in the storybook to toggle the value.

I assume that storybook screenshot is your local. Since I can't typically run Docker locally I was wondering if storybook was available as part of the CI (before we merge the PR)?

Copy link
Member

Choose a reason for hiding this comment

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

Running npm run storybook:dev should do the trick locally and doesn't require Docker. IIRC, there are no PR-specific builds for Storybook.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey folks, sorry for the delayed reply — not on Gutenberg much these days.

What I meant with #68927 (comment) was to add a new Storybook example that showcases ComboboxControl being used with async loading options, as we do for the author input.

@adamsilverstein and/or @Mamaduka , would any of you be up for this as a nice follow-up?

Copy link
Member

Choose a reason for hiding this comment

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

I'm unsure how to emulate async data in Storybook; I'm guessing with a setTimeout and Promise combo. Do we have any similar examples?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure, but yeah — that sounds reasonable. Maybe something like:

  • first render with empty (or a limited set of) options
  • when clicking a "load more options" button, we trigger an async request:
    • the request could be arbitrarily slowed down (promise with timeout);
    • while the data is loading, we show a spinner

WDYT ?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, sounds good.

I will add it to my list, but I'm unsure when I'll have time to work on it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good to me, definitely not a priority, rather a nice example to have. Thank you as always 🙏

@adamsilverstein adamsilverstein added [Type] Enhancement A suggestion for improvement. [Package] Components /packages/components Needs Design Feedback Needs general design feedback. labels Jan 31, 2025
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.

Thank you, @adamsilverstein! I think this is almost ready for merging.

I noticed that the spacing for the spinner icon is a bit off. Overriding the default margin with 0 should fix it.

P.S. We should also add the changelog entry for this change.

Before
CleanShot 2025-02-03 at 20 16 45

After
CleanShot 2025-02-03 at 20 17 43

packages/components/src/combobox-control/types.ts Outdated Show resolved Hide resolved
packages/components/src/combobox-control/types.ts Outdated Show resolved Hide resolved
@adamsilverstein
Copy link
Member Author

adamsilverstein commented Feb 4, 2025

I noticed that the spacing for the spinner icon is a bit off. Overriding the default margin with 0 should fix it.

Thanks for the feedback. Adjusted in e526287

@adamsilverstein
Copy link
Member Author

adamsilverstein commented Feb 4, 2025

P.S. We should also add the changelog entry for this change.

Good point. Added in 782d82a, please review, suggestions appreciated

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 for the follow-up, @adamsilverstein!

This looks good to merge.

P.S. CI checks failures look unrelated. It might be easier to restart all of them via rebasing.

CleanShot.2025-02-04.at.21.28.52.mp4

@Mamaduka Mamaduka changed the title Add a loading indicator (isLoading props) to ComboboxControl ComboboxControl: Add an isLoading prop to show a loading spinner Feb 5, 2025
@Mamaduka Mamaduka merged commit 589e763 into WordPress:trunk Feb 5, 2025
63 checks passed
@github-actions github-actions bot added this to the Gutenberg 20.3 milestone Feb 5, 2025
@ciampo
Copy link
Contributor

ciampo commented Feb 5, 2025

Thank you both for shipping this one, and for doing it in a separate PR from the editor change 🙏

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.

3 participants