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: Place children before the icon when iconPosition is "right" #59489

Merged
merged 2 commits into from Mar 2, 2024

Conversation

t-hamano
Copy link
Contributor

@t-hamano t-hamano commented Mar 1, 2024

Should be able to close #44042

What?

This PR renders children in front of the icon in the Button component when iconPosition is set to right. This change will always render the icon last if both children, text are used and iconPositon is right.

Example code:

<Button
	variant="primary"
	icon={ help }
	text="TextProp"
	iconPosition="right"
>
	TextChildren
</Button>

Before

image

After

image

Why?

In #44042, when the Button component has an icon, some issues were reported regarding the spacing and ordering between the icon and text.

These issues have been fixed in stages as a result of the following PRs.

However, the only problem still unresolved is that the icon is rendered before the children, even though the iconPosition is right.

How?

Simply swapped the order in which children is rendered. This change will result in a visual change for consumers using children, text, icon, iconPosition="right". However, there are probably no users who use both children and text and expect an icon to appear between them.

Note

As discussed in #56949, it seems that deprecation of the text prop is also being considered.

Testing Instructions

Screenshots or screencast

a709dc82413570b845c8dde54ed9f311.mp4

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Package] Components /packages/components labels Mar 1, 2024
@t-hamano t-hamano self-assigned this Mar 1, 2024
@t-hamano t-hamano requested a review from a team March 1, 2024 04:57
@t-hamano t-hamano marked this pull request as ready for review March 1, 2024 04:57
@t-hamano t-hamano requested a review from ajitbohra as a code owner March 1, 2024 04:57
Copy link

github-actions bot commented Mar 1, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: andrewhayward <andrewhayward@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Contributor

@andrewhayward andrewhayward left a comment

Choose a reason for hiding this comment

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

Change looks good 🚀

Bit weird how TextProp and TextChildren smoosh into each other, but that's outside the scope of this PR!

Copy link
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

Bit weird how TextProp and TextChildren smoosh into each other, but that's outside the scope of this PR!

Yeah, but I guess this is limited to this example. I'd say that if we attempt to fix this, it might actually break, or unexpectedly alter other existing usages that use either only children or text.

@t-hamano
Copy link
Contributor Author

t-hamano commented Mar 2, 2024

Thanks for the PR!

Bit weird how TextProp and TextChildren smoosh into each other, but that's outside the scope of this PR!

Based on my experience, I expect that there are almost no cases where the text prop and children are used together 😄

@t-hamano t-hamano merged commit 63acff0 into trunk Mar 2, 2024
63 checks passed
@t-hamano t-hamano deleted the button/change-children-order branch March 2, 2024 01:16
@github-actions github-actions bot added this to the Gutenberg 17.9 milestone Mar 2, 2024
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
Development

Successfully merging this pull request may close these issues.

Component: Order and spacing issues for text and icon in Button component
3 participants