Skip to content

Commit

Permalink
Patch - Core: Break words in paragraphs and headings only (#2467)
Browse files Browse the repository at this point in the history
* Theme: Set word-break to initial for table children

#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 #2466.

* Update sites/baseline/_scaffolding.scss

Co-authored-by: Garneauma <garneauma@gmail.com>

* Set word-break to initial for paragraphs in table cells
* 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

---------

Co-authored-by: Garneauma <garneauma@gmail.com>
  • Loading branch information
EricDunsworth and Garneauma authored Jan 27, 2025
1 parent add25e0 commit 193b77e
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions sites/baseline/_scaffolding.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
*
*/

%gcweb-scaffolding-word-break-break-word {
word-break: break-word;
}

//
// Apply baseline font styling
// For the font smooth, read the justification here: https://wet-boew.github.io/themes-dist/GCWeb/gcweb-theme/index.html#antialiasing
Expand All @@ -21,8 +25,20 @@ main {
font-size: 20px;
line-height: 1.65em;

* {
word-break: break-word;
h1, h2, h3, h4, h5, h6, p {
@extend %gcweb-scaffolding-word-break-break-word;
}

table {
caption {
p {
@extend %gcweb-scaffolding-word-break-break-word;
}
}

p {
word-break: initial;
}
}
}

Expand Down

0 comments on commit 193b77e

Please sign in to comment.