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

Theme: Break words in paragraphs and headings only #2467

Conversation

EricDunsworth
Copy link
Member

@EricDunsworth EricDunsworth commented Jan 23, 2025

#2450 added a CSS selector that set the word-break property to break-word anywhere within the main element.

But it had unexpected side effects in certain kinds of two-dimensional content, such as tables and input groups.

Specifically:

  • It could cause wide tables (even ones situated within table-responsive containers) to divide their columns improperly - resulting in individual numbers in number groupings "splitting" across lines, columns that are too narrow to fit short words on the same line, non-breaking spaces getting ignored, etc...
  • Buttons situated in input groups became "squished" - every letter within affected buttons appeared on its own line

This resolves it by reworking the selector to solely target paragraphs and headings. Paragraphs in table cells are exempted.

Fixes #2466.

CC @Garneauma @duboisp

wet-boew#2450 added a CSS selector that set the word-break property to break-word anywhere within the main element.

But it had unexpected side effects in certain kinds of two-dimensional content, such as tables. Specifically, it could cause wide tables (even ones situated within table-responsive containers) to divide their columns improperly - resulting in individual numbers in number groupings "splitting" across lines, columns that are too narrow to fit short words on the same line, non-breaking spaces getting ignored, etc...

This resolves it by adding overrides to reset the word-break properties of any table child elements to initial.

Fixes wet-boew#2466.
@EricDunsworth
Copy link
Member Author

EricDunsworth commented Jan 24, 2025

Btw I wanted to modify the original selector rule from main * to something along the lines of main :not(table, table *) to avoid needing an "undo" override... but it didn't work in practice since word-break is an inherited property.

For example, if the main element contains a div and a table is situated within... the table and its children will still inherit the div's word-break: break-word; property - even though the CSS selector doesn't directly apply to them.

There's no way around the need for an undo override. But if there's an appetite to fix the issue + keep word-break functioning as an inherited property on the table's children... it'd be possible to achieve via main :not(table *) {word-break: break-word;} and main table {word-break: initial;}.

@Garneauma @duboisp Would you prefer that I update this PR to use the alternate way? IMO it'd be better overall, at the cost of making the first selector slightly-more complex.

PS:
#2450 also negatively impacted the timers in the WET multimedia player's controls in some edge cases...

I was originally going to cover .wb-mm-txtonly * in the undo selector rule to fix it, but it turns out that GCWeb already has a media player override that does the trick.

@EricDunsworth
Copy link
Member Author

EricDunsworth commented Jan 24, 2025

This PR will probably need to be extended to cover input groups and maybe even buttons in general (e.g. .btn, button, input[type="submit"]).

Selectors that apply the display: table; and display: table-cell; properties might also need to be double-checked just in case.

sites/baseline/_scaffolding.scss Outdated Show resolved Hide resolved
@EricDunsworth EricDunsworth marked this pull request as draft January 27, 2025 16:10
* Prevents improper column division in cells containing paragraphs with long text (e.g. large dollar amounts, publication numbers, year ranges, etc...)
* Retains break-word in paragraphs situated within table captions
* Leverages a placeholder selector
@EricDunsworth EricDunsworth changed the title Theme: Set word-break to initial for table children Theme: Break words in paragraphs and headings only Jan 27, 2025
@EricDunsworth EricDunsworth marked this pull request as ready for review January 27, 2025 18:26
@EricDunsworth
Copy link
Member Author

Revised the PR as follows:

  • Merged @Garneauma's suggestion
  • Pushed another commit to exempt paragraphs situated in table cells (paragraphs in table captions are still covered since they function similarly to "regular" paragraphs)
  • Updated the PR's subject + OP to reflect what's changed and mention input groups

@Garneauma Garneauma merged commit 193b77e into wet-boew:master Jan 27, 2025
1 check passed
@Garneauma Garneauma added this to the v16.2.0 milestone Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug - Table header columns not rendering responsively
2 participants