Skip to content

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

Merged
Mamaduka merged 19 commits into
WordPress:trunkfrom
adamsilverstein:add/combobox-loading-spinner-combobox-only
Feb 5, 2025
Merged

ComboboxControl: Add an isLoading prop to show a loading spinner#68990
Mamaduka merged 19 commits into
WordPress:trunkfrom
adamsilverstein:add/combobox-loading-spinner-combobox-only

Conversation

@adamsilverstein
Copy link
Copy Markdown
Member

@adamsilverstein adamsilverstein commented Jan 31, 2025

What?

Add a loading indicator to the ComboboxControl component.

ComboboxControl only part of #68927

@github-actions
Copy link
Copy Markdown

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 <adamsilverstein@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>

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

</div>
);
},
isLoading: true,
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

Comment thread packages/components/src/combobox-control/types.ts Outdated
Comment thread packages/components/src/combobox-control/types.ts
@adamsilverstein
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

Comment thread packages/components/src/combobox-control/style.scss Outdated
@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
@github-actions github-actions Bot added this to the Gutenberg 20.3 milestone Feb 5, 2025
@ciampo
Copy link
Copy Markdown
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 🙏

Kallyan01 pushed a commit to Kallyan01/gutenberg that referenced this pull request Feb 24, 2025
…ordPress#68990)


Co-authored-by: adamsilverstein <adamsilverstein@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
chriszarate pushed a commit to chriszarate/gutenberg that referenced this pull request Jul 1, 2025
…ordPress#68990)


Co-authored-by: adamsilverstein <adamsilverstein@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
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