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: the small and compact sizes should not use a fixed width #63247

Open
afercia opened this issue Jul 8, 2024 · 0 comments
Open

Button: the small and compact sizes should not use a fixed width #63247

afercia opened this issue Jul 8, 2024 · 0 comments
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] Components /packages/components [Type] Bug An existing feature does not function as intended

Comments

@afercia
Copy link
Contributor

afercia commented Jul 8, 2024

Description

Splitting this out from #61761 (comment)

The compact and small sizes of the Button component use a fixed width. See the related CSS:

&.is-compact {
height: $button-size-compact;
&.has-icon:not(.has-text) {
padding: 0;
width: $button-size-compact;
min-width: $button-size-compact;
}
}
&.is-small {
height: $button-size-small;
line-height: 22px;
padding: 0 8px;
font-size: 11px;
&.has-icon:not(.has-text) {
padding: 0;
width: $button-size-small;
min-width: $button-size-small;
}
}

The fixed width is only applied when the buttons use an icon and don't contain text.

However, the current implementation of 'Show button text labels' preference in the editor doesn't use text. It uses CSS generated content. By setting a fixed width, these sizes aren't compatible with 'Show button text labels' as the CSS generatd text will overlap the surrounding content.

I'm not sure why a fixed width is necessary in the first place. Unless I'm missing something, when the Button contains an icon and don't contain text, a min-width woul dbe sufficient as the icon will not be greater than the button.

It appears the first fixed width was added long time ago for the small size in #19344

I'd tend to think all fixed widths should be removed, they seem unnecessary to me.

Step-by-step reproduction instructions

  • Go to the Storybook and select the Secondary button: https://wordpress.github.io/gutenberg/?path=/story/components-button--secondary
  • Note: the secondary button helps illustrate the issue because it has visible borders. The issue applies to all variants though.
  • Remove the children string "Code is poetry" and only keep two double quotes.
  • Set the icon prop to any icon.
  • Set the label prop to a pretty long string.
  • Set the size prop to compact or small.
  • In your dev tools, inspect the button and observe it has a fixed width.
  • Remove the fixed width.
  • Observe that nothing changes.

Emulating what would happen with the editor 'Show button text labels' preference enabled:

Screenshot 2024-07-08 at 15 43 21

More screenshots at #61761

Screenshots, screen recording, code snippet

No response

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

@afercia afercia added [Type] Bug An existing feature does not function as intended [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] Components /packages/components labels Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] Components /packages/components [Type] Bug An existing feature does not function as intended
1 participant