-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Menu.ItemHelpText: better line breaking #67011
Menu.ItemHelpText: better line breaking #67011
Conversation
Changed break-all to use word-break for better readability.
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @himanshupathak95! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your PR @himanshupathak95
It's testing nicely to me.
Screen.Recording.2024-11-19.at.18.12.50.mov
Can you please add an entry on the unreleased section of the changelog for components?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can see that the original rule was put in place (#63916) with a pretty specific case in mind — a URL with a hyphen in the middle, like https://m.media-amazon.com/images/M/MV5BOTI5ZTNkYWQtNDg2Mi00MTBmLTliMGItNTI5YWI5OTZkM2Y2XkEyXkFqcGdeQXVyNzU1NzE3NTg@._V1_QL75_UX500_CR0,47,500,281_.jpg
.
I do understand that break-all
is not acceptable for wrapping (even if it's fine for truncation) in normal text, so I think reverting to word-break: normal
is sensible.
Though we will see non-ideal wrapping for certain URLs, I think it's an acceptable compromise as long as they don't overflow and break the container, as was the original intent of the break-all
:
cc @ciampo for a gut check.
@@ -380,7 +380,7 @@ export const MenuItemHelpText = styled( Truncate )` | |||
font-size: ${ font( 'helpText.fontSize' ) }; | |||
line-height: 16px; | |||
color: ${ LIGHTER_TEXT_COLOR }; | |||
word-break: break-all; | |||
word-break: break-word; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
word-break: break-word
is deprecated, so we should use the non-deprecated equivalent:
word-break: break-word; | |
overflow-wrap: anywhere; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @mirka, Thanks for the suggestion.
I have made the suggested changes. Please let me know if there is anything else that can be done.
Replace deprecated `word-break: break-word` with the modern equivalent `overflow-wrap: anywhere` to handle text wrapping. This change maintains the same text wrapping behavior while using the current standard CSS property.
@himanshupathak95 When making changes to WordPress components, it’s important to add a changelog entry in packages/components/CHANGELOG.md. At the top of this file, you’ll find an “Unreleased” section, which is where you should add your entry. This ensures the changes are included in the next release. Within the “Unreleased” section, there are sub-sections like “Bug Fixes” and “Enhancements.” Add your entry under the most appropriate sub-section, following the standard format:
|
Thanks, @juanfra for the suggestion. I have now added the appropriate entry in Please let me know if there is anything else that can be done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix seems sensible to me, thank you for the ping @mirka !
Left a couple of minor comments, we can merge this PR once they are addressed
packages/components/CHANGELOG.md
Outdated
@@ -14,6 +14,7 @@ | |||
- `ToggleGroupControl`: Fix active background for `0` value ([#66855](https://github.com/WordPress/gutenberg/pull/66855)). | |||
- `SlotFill`: Fix a bug where a stale value of `fillProps` could be used ([#67000](https://github.com/WordPress/gutenberg/pull/67000)). | |||
- `ColorPicker`: Add accessible label for copy button ([#67094](https://github.com/WordPress/gutenberg/pull/67094)). | |||
- `MenuItemHelpText`: Fix text wrapping to prevent unintended word breaks by using `overflow-wrap: anywhere` ([#67011](https://github.com/WordPress/gutenberg/pull/67011)). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: adding a dot to represent the current component name
- `MenuItemHelpText`: Fix text wrapping to prevent unintended word breaks by using `overflow-wrap: anywhere` ([#67011](https://github.com/WordPress/gutenberg/pull/67011)). | |
- `Menu.ItemHelpText`: Fix text wrapping to prevent unintended word breaks by using `overflow-wrap: anywhere` ([#67011](https://github.com/WordPress/gutenberg/pull/67011)). |
packages/components/CHANGELOG.md
Outdated
@@ -14,6 +14,7 @@ | |||
- `ToggleGroupControl`: Fix active background for `0` value ([#66855](https://github.com/WordPress/gutenberg/pull/66855)). | |||
- `SlotFill`: Fix a bug where a stale value of `fillProps` could be used ([#67000](https://github.com/WordPress/gutenberg/pull/67000)). | |||
- `ColorPicker`: Add accessible label for copy button ([#67094](https://github.com/WordPress/gutenberg/pull/67094)). | |||
- `MenuItemHelpText`: Fix text wrapping to prevent unintended word breaks by using `overflow-wrap: anywhere` ([#67011](https://github.com/WordPress/gutenberg/pull/67011)). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another nit, but I think that the ### Internal
section would be more fitting for this CHANGELOG entry, given that the component is still a private API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @ciampo, Thanks for the suggestions.
I have addressed all the feedback. Please let me know if there is anything else that can be done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thank you for the follow-ups!
Fixes: #66998
What?
Changed CSS word-break property from
break-all
tobreak-word
in meta fields for better text readability when content wraps.Why?
Currently, text in meta fields breaks incorrectly within words (e.g., "white" breaks as "whit e") due to using
break-all
. This creates poor readability, especially for descriptions and long text content. Usingbreak-word
ensures text breaks at appropriate word boundaries.Testing Instructions
functions.php
in your theme:Screenshots
Before
word-break: break-all;
:After
word-break: break-word;
: