-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Button, Icon: fix iconSize prop doesn't work with some icons #43821
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
Conversation
|
This PR has changed the order of the attributes of the |
| } ); | ||
|
|
||
| it( 'renders an svg element and passes the size as its width and height', () => { | ||
| it( 'renders an svg element and override its width and height', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is originally intended to test that the width/height of the svg element is respected, but should be overridden by the size prop of the Icon component.
|
Size Change: +393 B (0%) Total Size: 1.25 MB
ℹ️ View Unchanged
|
mirka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works great, thanks 👍
Just to clarify so others don't get confused by the PR description: This fix is in the @wordpress/components Icon component, not the @wordpress/icons Icon. The wp-icons Icon component already works as expected on trunk.
packages/components/CHANGELOG.md
Outdated
|
|
||
| ### Bug Fix | ||
|
|
||
| - `Button`: Fix `iconSize` prop doesn't work with some icons ([#43821](https://github.com/WordPress/gutenberg/pull/43821)). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably also want to mention that it was fixed in the Icon component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed by 6c4d6a3
Thanks for pointing that out! The sample code I presented contains the wrong test 😅 Is this title appropriate as a commit message at merge time? |
Works for me 👍 |
Fix #43745
What?
This PR fixes an issue where theiconSizeprop of theButtoncomponent was not reflected in some icons.This PR fixes a problem in the
@wordpress/componentspackage where theiconSizeprop of theButtonandIconcomponent was not reflected in some icons.Why?
This is because the
iconSizeprop is overridden if the icon's svg element has awidth/heightattribute, as noted in this comment.The following are those icons:
How?
In the internal Icon component, I have made the passed props (such as iconSize) take precedence over the attributes of the SVG element.
Testing Instructions
Rewrite edit.js for any of the core blocks as follows and confirm that they all render at the expected size:
@add: This example also uses
@wordpress/iconsIcon, which is incorrect. It's not a problem with the@wordpress/iconspackage, as this comment states.helpicon on the left has no width / height attributes on the svg element.helpFilledicon on the right has width / height attributes on the svg element.On trunk
ON this branch
Screenshots or screencast