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

Menu: Truncation breaks with break-all rather than break-word #66998

Closed
jasmussen opened this issue Nov 14, 2024 · 6 comments · Fixed by #67011
Closed

Menu: Truncation breaks with break-all rather than break-word #66998

jasmussen opened this issue Nov 14, 2024 · 6 comments · Fixed by #67011
Labels
[Package] Components /packages/components [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@jasmussen
Copy link
Contributor

Example:

Image

Shown here, the following description breaks inside block attributes due to truncation using break-all instead of break-word:

Inspired by the Eiffel Tower, this red and white tower is one of Tokyo's most recognizable landmarks. It offers observation decks with sweeping views of the city.

Suggestion: use break-word instead.

@jasmussen jasmussen added the [Type] Bug An existing feature does not function as intended label Nov 14, 2024
@jasmussen
Copy link
Contributor Author

CC: @WordPress/gutenberg-components in case this resonates!

@im3dabasia
Copy link
Contributor

Hi @jasmussen,

Thank you for raising this issue! Could you please provide the steps to reproduce it? That would be really helpful.

@jasmussen
Copy link
Contributor Author

Try this code in your functions.php:
function init_test_meta_fields() {
	register_post_type(
		'landmark',
		array(
			'label'        => 'Landmark',
			'public'       => true,
			'supports'     => array( 'title', 'editor', 'comments', 'revisions', 'trackbacks', 'author', 'excerpt', 'page-attributes', 'thumbnail', 'custom-fields', 'post-formats' ),
			'has_archive'  => true,
			'show_in_rest' => true,
		),
	);
	register_meta(
		'post',
		'landmark_description',
		array(
			'object_subtype' => 'landmark',
			'label'          => 'Description',
			'show_in_rest'   => true,
			'single'         => true,
			'type'           => 'string',
			'default'        => 'Inspired by the Eiffel Tower, this red and white tower is one of Tokyo\'s most recognizable landmarks. It offers observation decks with sweeping views of the city.',
		)
	);
}

add_action( 'init', 'init_test_meta_fields' );

Then create a new post of the "Landmark" type, then edit that post and click attributes, and open the content flyout.

@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Nov 14, 2024
@im3dabasia
Copy link
Contributor

Thank you, @jasmussen, for providing the code snippet. I was able to replicate the issue, and the patch in PR #67011 effectively resolves it. The break-word property now shifts the entire word to a new line, as shown in the "After" screenshot.

I tested the solution, and it works as expected. ✅

Before After
Before After

@mirka mirka added the [Package] Components /packages/components label Nov 14, 2024
@jasmussen
Copy link
Contributor Author

Nice, thanks for the contribution!

@mirka mirka changed the title Truncate: Truncation breaks with break-all rather than break-word Menu: Truncation breaks with break-all rather than break-word Nov 19, 2024
@mirka
Copy link
Member

mirka commented Nov 19, 2024

Tweaking the issue title since this is a characteristic of the Menu.ItemHelpText component specifically, not Truncate (which is word-break: normal).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Components /packages/components [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants