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

Block Variation Picker: adds support to declarated icon with src #46373

Merged
merged 2 commits into from
Dec 21, 2022

Conversation

gigitux
Copy link
Contributor

@gigitux gigitux commented Dec 7, 2022

What?

This PR adds the support of a declared icon with src to the Block Variation Picker.

Why?

This avoids the crash of the Block Variation Picker when a variation has a declared icon with src. Fixes #46372.

How?

Testing Instructions

  1. Create a Query Loop variation that has a declared icon with src (you can use this code).
  2. Add the Query Loop block.
  3. Click Start Blank.
  4. Be sure the Block Variation Picker doesn't crash.

Screenshots or screencast

Screen.Capture.on.2022-12-07.at.17-58-27.mp4

@github-actions
Copy link

github-actions bot commented Dec 7, 2022

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @gigitux! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Dec 7, 2022
@@ -43,7 +43,7 @@ function BlockVariationPicker( {
<li key={ variation.name }>
<Button
variant="secondary"
icon={ variation.icon }
icon={ variation.icon.src || variation.icon }
Copy link
Member

Choose a reason for hiding this comment

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

Most code guards against icon being undefined using "variation.icon && variation.icon.src ? variation.icon.src : variation.icon". I guess we can follow a similar approach but other that the change looks good and can be merged after the update.

@Mamaduka Mamaduka added [Type] Bug An existing feature does not function as intended [Feature] Block Variations Block variations, including introducing new variations and variations as a feature labels Dec 9, 2022
@gigitux
Copy link
Contributor Author

gigitux commented Dec 9, 2022

@jorgefilipecosta Thanks for the review! I updated the check!

@Aljullu
Copy link
Contributor

Aljullu commented Dec 16, 2022

@gigitux given that this PR was approved and you did the change, should we go ahead and merge?

@gigitux
Copy link
Contributor Author

gigitux commented Dec 16, 2022

@gigitux given that this PR was approved and you did the change, should we go ahead and merge?

For me, it makes sense. Unfortunately, I don't have permission to merge the PR (I think that @ellatrix must approve the PR).

cc @jorgefilipecosta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block Variations Block variations, including introducing new variations and variations as a feature First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Block Variation Picker doesn't support icons registered with the src attribute.
5 participants