#60892 closed defect (bug) (fixed)
About Page: `text-wrap: balance;`adds unintended new lines in Japaneese
Reported by: | wildworks | Owned by: | ryelle |
---|---|---|---|
Milestone: | 6.6.2 | Priority: | normal |
Severity: | normal | Version: | 6.5 |
Component: | Help/About | Keywords: | has-patch commit fixed-major dev-reviewed |
Focuses: | Cc: |
Description
In the about page of WordPress 6.5, text-wrap:balance
is applied to the h1/h2/h3/h4 elements.
This may work beautifully in Latin languages, but it adds unintended new lines, at least in Japanese.
For example, let's take the heading "Add and manage fonts across your site" as an example. In English, it is displayed as follows:
Add and manage fonts across your site
On the other hand, in Japanese, it is displayed as follows:
サイト全体へのフォ ントの追加と管理
The words are wrapped in the middle, but if you compare it to English, it is similar to how it would be displayed as shown below.
Add and man age fonts across your site
At least in Japanese, I would expect no wrapping at all, that is, the text would be wrapped to fit the width of the container.
I would be happy if someone could test what effect text-wrap:balance
has on other CJK languages.
Attachments (4)
Change History (35)
#1
@
6 months ago
For reference, the Rosetta site has added processing to initialize text-wrap
in specific locales.
#3
@
8 weeks ago
- Milestone changed from Awaiting Review to 6.6.2
My apologies that this never received attention during the 6.5 minor release cycles, @wildworks.
I was thinking now that 6.5 is unsupported, we should probably close this out as wontfix
. But I checked the 6.6 About page and it seems that text-wrap: balance
is still in use.
Moving this to 6.6.2 to hopefully address in the next minor release.
#4
@
7 weeks ago
@desrosj Thanks for the reply.
I checked to see if this problem occurs in 6.6.1, and it does exist. I would suggest either deleting text-wrap: balance;
altogether, or not applying this style depending on the locale.
This ticket was mentioned in Slack in #core by hellofromtonya. View the logs.
5 weeks ago
#6
follow-up:
↓ 7
@
5 weeks ago
- Keywords needs-patch needs-testing added
Discussed in today's bugscrub:
A patch and testing of the patch are needed. Keywords updated.
But as @wildworks noted, the patch needs to consider how it will affect other locales? Does removing text-wrap: balance;
affect other locales? Need to test to find out.
FYI: Tentatively planning 6.6.2 RC1 for the week of Aug 19th.
#7
in reply to:
↑ 6
@
5 weeks ago
Replying to hellofromTonya:
But as @wildworks noted, the patch needs to consider how it will affect other locales? Does removing
text-wrap: balance;
affect other locales? Need to test to find out.
This was reported on the WordPress.org site as well, and the solution there was to only remove it on ja.w.org using text-wrap: unset
. I haven't heard from any other locale that this is a problem on their sites, but that doesn't mean they're not out there.
I think design requested balance, though I can't find that discussion now. I know there is similar usage in Gutenberg.
Personally, I think the "balance" wrapping feels extreme in English too, I prefer "pretty" (where supported, not Firefox), which just prevents orphans.
So all of that is to say that it can be removed on just Japanese, but to change it everywhere would need input from a designer.
#8
@
5 weeks ago
Thanks everyone for your feedback.
I haven't found an ideal approach, but I can think of three approaches:
- Use
text-wrap:pretty
instead oftext-wrap:balance
. This approach will have a bigger impact because it will change the wrapping position of headings in all locales. - Override
text-wrap
in specific locales. This approach would require a selector likehtml[lang="ja"]
, and using a selector hardcoded for a specific locale in the core may not be ideal. - Add
word-break: auto-phrase
. This value is only valid whenlang="ja"
is specified, so it will not affect other locales. However, it is not supported by Firefox and Safari (MDN link).
This ticket was mentioned in PR #7209 on WordPress/wordpress-develop by @akshat2802.
4 weeks ago
#9
- Keywords has-patch added; needs-patch removed
This is a sample PR to conditionally add text-wrap property in about page CSS based on locale.
https://core.trac.wordpress.org/ticket/60892
This ticket was mentioned in Slack in #core by hellofromtonya. View the logs.
4 weeks ago
@sabernhardt commented on PR #7209:
4 weeks ago
#11
If a language-specific correction is preferable, that is possible with only CSS:
.about__container :is(h1, h2, h3, h4):lang(ja) { text-wrap: unset; }
And *if* someone identifies another language that needs the same style (for example, Korean), the languages could be grouped inside another :is()
.
.about__container :is(h1, h2, h3, h4):is(:lang(ja), :lang(ko)) { text-wrap: unset; }
The :is()
selector is compatible with browsers that WordPress admin supports.
@wildworks commented on PR #7209:
3 weeks ago
#12
@akshat2802 commented on PR #7209:
3 weeks ago
#13
Thanks, @t-hamano for the review.
I have addressed the comments in the new commit.
@akshat2802 commented on PR #7209:
3 weeks ago
#14
Sure @t-hamano,
I probably missed comment the second comment by @sabernhardt.
Added changes according to the suggestion.
#15
@
3 weeks ago
Looks like this is also an issue in Korean (see related comments here) — and there @gonom9 suggests adding word-break: keep-all;
to keep words together. This works for Korean because there are spaces between words, trying to add this to Japanese created overflow.
I think the solution in PR 7209 is best for Japanese, plus a separate CSS rule for Korean adding word-break: keep-all;
.
#16
@
3 weeks ago
This ticket was originally intended for Japanese only, but there might be other languages to consider besides Korean, as mentioned by @ryelle.
For example, Chinese and Thai are languages that don't typically use spaces between words. These languages also wrap title text on the About page, but I don't have the knowledge to judge whether text with text-wrap:balance
applied is easy to read or not in these languages.
If this ticket needs to take all languages into account, it seems unrealistic to test each language individually and apply the appropriate text-wrap to each one. As mentioned in this comment, how about applying text-wrap: pretty;
to all languages?
#17
@
3 weeks ago
Replying to wildworks:
This ticket was originally intended for Japanese only
That's a fair point— in that case, the PR as it is could ship and fix the ticket.
If this ticket needs to take all languages into account, it seems unrealistic to test each language individually and apply the appropriate text-wrap to each one.
Maybe we can do the inverse here, and add balance
for :lang(en)
? If I understand the selector correctly, that should catch all English locales.
As mentioned in this comment, how about applying text-wrap: pretty; to all languages?
Again, this doesn't work in Firefox or Safari yet, but if we don't want to go case by case, that would work.
#18
follow-up:
↓ 22
@
3 weeks ago
add balance for :lang(en)? If I understand the selector correctly, that should catch all English locales.
This should be correct. Furthermore, what about adding text-wrap:pretty
for languages other than English? text-wrap:pretty
should have no effect on CJK languages.
.about__container :is(h1, h2, h3, h4) { text-wrap: pretty; } .about__container :is(h1, h2, h3, h4):lang(en) { text-wrap: balance; }
This ticket was mentioned in Slack in #core by hellofromtonya. View the logs.
3 weeks ago
@akshat2802 commented on PR #7209:
2 weeks ago
#20
Hii @ryelle @t-hamano waiting for your final review. Addressed all suggested changes. 😃
@wildworks commented on PR #7209:
2 weeks ago
#21
@AKSHAT2802 Thanks for the update.
We are discussing in the core ticket what would be a more ideal approach.
Please see https://core.trac.wordpress.org/ticket/60892.
#22
in reply to:
↑ 18
@
2 weeks ago
Replying to wildworks:
This should be correct. Furthermore, what about adding
text-wrap:pretty
for languages other than English?text-wrap:pretty
should have no effect on CJK languages.
Sounds good to me— there will be people who are on browsers that don't have pretty
support in languages where balance
would still work (for example a Spanish user in Firefox), but that's better than the current situation where balance
for everyone makes it hard to read.
#23
@
2 weeks ago
@ryelle Thanks for the reply.
So the code proposed in this comment (https://core.trac.wordpress.org/ticket/60892#comment:18) seems like the most logical approach for now.
Should we update the PR that @akshat2802 submitted? Or would it be better to create a new patch?
@
13 days ago
This patch applies text-wrap:pretty to heading elements, and text-wrap:balance to heading elements in English locale only.
#24
@
13 days ago
I created a patch (patch.diff) based on this comment.
Even if the heading wrapping is unnatural in Japanese, we have no problem reading it. Therefore, I don't think this ticket is a big problem, but I would be happy if it was included in the 6.6 minor release.
This ticket was mentioned in Slack in #core by hellofromtonya. View the logs.
13 days ago
#26
@
12 days ago
- Owner set to ryelle
- Resolution set to fixed
- Status changed from new to closed
In 58976:
#27
@
12 days ago
- Keywords dev-feedback fixed-major added
- Resolution fixed deleted
- Status changed from closed to reopened
Reopening for a second committer to backport [58976], pinging @hellofromTonya since you mentioned doing that. and thanks for your help with the process!
#28
@
12 days ago
Thanks for ping and committing it to trunk
. Yes, I'll take care of reviewing and backporting to 6.6 branch.
#29
@
12 days ago
- Keywords commit dev-reviewed added; needs-testing dev-feedback removed
[58976] LGTM.
I'm in the process of backporting it to the 6.6 branch.
@hellofromTonya commented on PR #7209:
12 days ago
#31
Committed with a few tweaks via https://core.trac.wordpress.org/changeset/58976. Thanks everyone for your contributions 🌟
Actual and expected display