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

Button: iconSize prop doesn't work with some icons #43745

Closed
t-hamano opened this issue Aug 31, 2022 · 4 comments · Fixed by #43821 · May be fixed by #43747
Closed

Button: iconSize prop doesn't work with some icons #43745

t-hamano opened this issue Aug 31, 2022 · 4 comments · Fixed by #43821 · May be fixed by #43747
Assignees
Labels
[Package] Components /packages/components [Type] Bug An existing feature does not function as intended

Comments

@t-hamano
Copy link
Contributor

Description

I have found that the size is not applied to some of the @wordpress/icons when I specify the iconSize attribute on a button component with SVG icons.
These icons will be displayed at the expected size when the size is specified in the Icons component, not the Button component.

I checked the icon library and found that icons with width / height attributes of the svg element match those with no size applied. I don't know why these icons don't reproduce when used in the Icons component, but I think SVG icons should be rendered at the size specified in the Icons component and the width / height attributes are unnecessary on the svg element.

The following are those icons:

Step-by-step reproduction instructions

I have rewritten edit.js in the code block to include code that designates all icons in @wordpress/icons as buttons:

import { useBlockProps } from '@wordpress/block-editor';
import * as Icons from '@wordpress/icons';
import { Button, Flex } from '@wordpress/components';

const { Icon, ...availableIcons } = Icons;

export default function CodeEdit() {
	const blockProps = useBlockProps();
	return (
		<div { ...blockProps }>
			<Flex
				wrap="wrap"
				justify="flex-start"
				style={ { textAlign: 'center', fontSize: '8px' } }
			>
				{ Object.entries( availableIcons ).map( ( [ name, icon ] ) => {
					return (
						<div key={ name } style={ { width: '5%' } }>
							<Button icon={ icon } iconSize={ 40 } />
						</div>
					);
				} ) }
			</Flex>
		</div>
	);
}

Screenshots, screen recording, code snippet

The icon circled in red has width and height specified for the svg element and the iconSize property is not applied.

icons

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Package] Components /packages/components labels Aug 31, 2022
@t-hamano t-hamano self-assigned this Aug 31, 2022
@Mamaduka
Copy link
Member

I think removing hardcoded sizes should fix the issue. There's #41772, but it's hard to see actual changes because of the bad rebase.

@t-hamano
Copy link
Contributor Author

Oh, I was just about to create #43747 😅
Should we wait for #41772 to be properly rebased?

@Mamaduka
Copy link
Member

Do feel free to create a new PR 👍 I think that one was only fixing line-(dashed|dottted|solid).js files. Maybe fix them as well, since PR hasn't been active for almost 40 days.

@t-hamano
Copy link
Contributor Author

I checked the latest trunk and it appears that those three icons were fixed in another PR, #40315.
Therefore, regarding #41772, it looks like we will have to close it, unfortunately.

Since the problem I have found is different from the icons improved above, I would like to activate my PR.

@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Aug 31, 2022
@priethor priethor removed the [Status] In Progress Tracking issues with work in progress label Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Components /packages/components [Type] Bug An existing feature does not function as intended
Projects
None yet
3 participants