-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Button, Icon: fix iconSize prop doesn't work with some icons #43821
Conversation
This PR has changed the order of the attributes of the |
@@ -63,7 +63,7 @@ describe( 'Icon', () => { | |||
expect( wrapper.prop( 'height' ) ).toBe( 24 ); | |||
} ); | |||
|
|||
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
|
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
@@ -4,12 +4,13 @@ | |||
|
|||
### 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 theiconSize
prop of theButton
component was not reflected in some icons.This PR fixes a problem in the
@wordpress/components
package where theiconSize
prop of theButton
andIcon
component was not reflected in some icons.Why?
This is because the
iconSize
prop is overridden if the icon's svg element has awidth
/height
attribute, 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/icons
Icon, which is incorrect. It's not a problem with the@wordpress/icons
package, as this comment states.help
icon on the left has no width / height attributes on the svg element.helpFilled
icon on the right has width / height attributes on the svg element.On trunk
ON this branch
Screenshots or screencast