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

Component: Button text is hidden in certain variations #44043

Closed
t-hamano opened this issue Sep 10, 2022 · 1 comment · Fixed by #56949
Closed

Component: Button text is hidden in certain variations #44043

t-hamano opened this issue Sep 10, 2022 · 1 comment · Fixed by #56949
Labels
[Package] Components /packages/components [Type] Bug An existing feature does not function as intended

Comments

@t-hamano
Copy link
Contributor

Description

In the Button component, the button text is cut off when the following conditions are met:

  • Specify text with text prop
  • Specify the icon with icon prop
  • Enable isSmall prop

When the above condition is met, the width of the button is fixed at 24px, regardless of the length of the text.
I think the cause is that the has-text class is not applied when text is specified by the text prop.

'has-text': !! icon && !! children,

Perhaps this issue is also related to #44042.
If the response to #44042 takes into account has-text class in the text prop, I believe this issue will be resolved as well.

Step-by-step reproduction instructions

To check the behavior of the current button component, I used the following code in the core/code block.

/**
 * WordPress dependencies
 */
import { useBlockProps } from '@wordpress/block-editor';
import { Button, Flex } from '@wordpress/components';
import { help } from '@wordpress/icons';

export default function CodeEdit() {
	const blockProps = useBlockProps();
	return (
		<div { ...blockProps }>
			<p>only text</p>
			<Flex gap={ 3 } justify="flex-start">
				<Button text="TextProp" variant="primary" />
				<Button variant="primary">TextChildren</Button>
			</Flex>

			<p>text and icon</p>
			<Flex gap={ 3 } justify="flex-start">
				<Button icon={ help } text="TextProp" variant="primary" />
				<Button icon={ help } variant="primary">
					TextChildren
				</Button>
			</Flex>

			<p>text and isSmall</p>
			<Flex gap={ 3 } justify="flex-start">
				<Button text="TextProp" variant="primary" isSmall />
				<Button variant="primary" isSmall>
					TextChildren
				</Button>
			</Flex>

			<p>text, icon and isSmall</p>
			<Flex gap={ 3 } justify="flex-start">
				<Button
					icon={ help }
					text="TextProp"
					variant="primary"
					isSmall
				/>
				<Button icon={ help } variant="primary" isSmall>
					TextChildren
				</Button>
			</Flex>
		</div>
	);
}

Screenshots, screen recording, code snippet

isSmall

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 Sep 10, 2022
@ciampo
Copy link
Contributor

ciampo commented Sep 12, 2022

cc'ing @mirka for visibility

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
Status: Done 🎉
Development

Successfully merging a pull request may close this issue.

2 participants