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

Fix Truncate component for long unbreakable text. #61137

Merged
merged 1 commit into from May 9, 2024

Conversation

afercia
Copy link
Contributor

@afercia afercia commented Apr 26, 2024

Fixes #61125
Amends #60890
See #60860

What?

#60890 broke the display of text that uses the Truncate component making words always 'breakable'. When the Truncate component forces text in one line, we still need to make sure 'unbreakable' text can break otherwise the -webkit-line-clamp CSS property will not work. However, when the Truncate component is set to force 2 or more lines, the text should not be forced to be 'breakable'.

Why?

When the Truncate component forces text in one line, we still need to make sure 'unbreakable' text can break otherwise the -webkit-line-clamp CSS property will not work. However, when the Truncate component is set to force 2 or more lines, the text should not be forced to be 'breakable'.

How?

Makes Truncate use word-break: break-all only when -webkit-line-clamp is 1.

Testing Instructions

  • Repeat the reproduction instructions from the issue LinkControl: LInk preview buttons are off-view when the link text is a very long url #60860
  • Observe long URls in the link preview are truncated.
  • Observe the buttons 'Edit link', 'Remove link', and 'Copy link' are visible
  • Open the block inserter.
  • Search for blocks with long titles that go in two or 3 lines e.g. 'Table of Contents' or 'Comments Form' or 'Latest Comments'
  • Observe the block titles don't have words that break in a new line.

Note: other places to optionally check are, for example, the filename of the Site Logo image, see screenshot:

Screenshot 2024-04-26 at 09 55 19

or the filename of the background image of a Group block.

Notice in these cases the element rendered by the Truncate component already receives some more custom CSS rules including word-break: break-all because filenames, like URLs, can be very long and 'unbreakable'. We could consider to remove the custom word-break: break-all set on these elements to be more clean, but keeping it doesn't harm much.

Testing Instructions for Keyboard

Screenshots or screencast

@afercia afercia added [Type] Bug An existing feature does not function as intended [Package] Block editor /packages/block-editor [Feature] Link Editing Link components (LinkControl, URLInput) and integrations (RichText link formatting) labels Apr 26, 2024
@afercia afercia requested a review from ajitbohra as a code owner April 26, 2024 08:24
@afercia afercia requested a review from richtabor April 26, 2024 08:25
Copy link

github-actions bot commented Apr 26, 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: afercia <afercia@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: richtabor <richtabor@git.wordpress.org>

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

@afercia afercia requested a review from Mamaduka April 26, 2024 14:00
@Mamaduka Mamaduka requested a review from a team April 26, 2024 14:59
Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

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

The change looks good to me, but I would appreciate a second opinion from folks who are more familiar with the Components package.

@richtabor
Copy link
Member

@WordPress/gutenberg-components mind taking a look at this? 🙏

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.

Thanks @afercia!

I think this is a reasonable compromise 👍

Also, confirmed that it fixes #61125 and that it tests well according to test instructions.

@afercia
Copy link
Contributor Author

afercia commented May 9, 2024

Thanks Marin for your review.

@afercia afercia merged commit 78e53bb into trunk May 9, 2024
70 of 71 checks passed
@afercia afercia deleted the fix/truncate-component-long-unbreakable-text branch May 9, 2024 13:38
@github-actions github-actions bot added this to the Gutenberg 18.4 milestone May 9, 2024
@afercia
Copy link
Contributor Author

afercia commented May 9, 2024

Sorry I missed to add the Co-authored-by comments 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Link Editing Link components (LinkControl, URLInput) and integrations (RichText link formatting) [Package] Block editor /packages/block-editor [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improper Inserter block title text wrapping
4 participants