Skip to content

fix(foundation): hyphenate long heading words where the language allows - #1701

Merged
gregpriday merged 4 commits into
developfrom
feature/issue-1472-break-long-localized-headings-at
Nov 28, 2026
Merged

gregpriday merged 4 commits into
developfrom
feature/issue-1472-break-long-localized-headings-at

Conversation

@gregpriday

Copy link
Copy Markdown
Member

Foundation's headings broke a word too long for its line (a German compound such as "Hochwasserschutzmaßnahmen" in the Split hero) at whatever letter reached the edge, with no hyphen ("Hochwassersch" / "utzmaßnahmen"). The theme's only rule for long words was overflow-wrap: anywhere on the body. Headings now ask the browser to hyphenate long words where the page's language allows. The emergency break stays as the last resort, for languages the browser has no dictionary for.

Resolves #1472

Changes

  • The h1–h6 rule in the base CSS of both committed releases (foundation, foundation-alt) adds hyphens: auto (and -webkit-hyphens) with hyphenate-limit-chars: 12 5 5. Only words of 12 letters or more hyphenate, at least 5 letters in from either end, so a shorter word still moves to the next line whole. Older Safari ignores hyphenate-limit-chars, so -webkit-hyphenate-limit-before/after: 5 keep the same margins there.
  • Hyphenation follows the page's lang, which the export already declares. The Japanese, Chinese and Korean heading rules are unchanged and still govern those scripts.
  • resources/packs.lock.json carries the new pack.json digests. The private builder-components source needs the same change, or a refresh from the pinned commit will revert it.

In Chromium at a 358 px column, the issue's heading now reads "Hochwasser-" / "schutzmaß-" / "nahmen für das" / "Mündungsge-" / "biet." Before, it read "Hochwassersch" / "utzmaßnahmen" / … / "Mündungsgebiet" / ".".

Testing

  • New tests/unit/foundation-heading-hyphenation.test.ts. It checks the rule in both releases, and in Playwright Chromium checks the computed hyphens and that the word stays inside the heading. Where the browser has a German dictionary, it also checks three things: the long word breaks only at a German syllable at least 5 letters from either end (with emergency wrapping off), a hyphens: manual control leaves the word unbroken, and the 11-letter "Wasserstand" stays whole although the browser alone splits it as "Wasser-stand". Those dictionary checks report a skip where the browser ships no German dictionary. All six browser checks failed before the change, and all pass on macOS Chromium with nothing skipped.
  • Pack-reading tests run beside it: committed-packs, theme-packs, pack-loader, packs-gate, pack-previews-render, foundation-html, foundation-surface-contrast, foundation-interactive-browser, foundation-text-link-arrow, collection-templates and data-table-print, all green. After the last rebase, contact-form and foundation-field-message-language also ran, all green. That is 12 of 664 unit test files (the import-graph selector reaches none of them, since they read pack.json through fs).

- headings ask for automatic hyphenation of words of 12 letters or
  more, broken at least 5 letters from either end (with Safari's
  prefixed limits for versions without hyphenate-limit-chars), so a
  long German compound in a display heading breaks at a syllable with
  a visible hyphen instead of at whatever letter reached the edge
- the body's overflow-wrap: anywhere stays the last resort for a
  language the browser has no dictionary for
- test the rule in both releases, and in a real browser the break, a
  hyphens: manual control and an 11-letter word that stays whole,
  skipping visibly where the browser has no German dictionary
- refresh the Foundation pack digests
@gregpriday
gregpriday force-pushed the feature/issue-1472-break-long-localized-headings-at branch from deaf16a to e850432 Compare November 28, 2026 10:27
@gregpriday

Copy link
Copy Markdown
Member Author

CI's Unit tests run on e8504329 failed on two tests outside this change. Both fail the same way on the PR's base (89cf1ce0a) and on current develop (3ccc6da7c) when run alone:

  • tests/unit/inspector-anchor-field-browser.test.ts › "leaves it out of code that places no id, unless it still has an anchor to clear": strict mode violation, getByLabel('Anchor ID') resolved to 2 elements.
  • tests/unit/redirect-form-browser.test.ts › "names the draft at an old address, which takes it over once it is published (Assigning a kept public address to a draft removes its redirect #1363)": the redirect row text no longer matches /About \(\/about\/\)\s+Added by …/.

tests/unit/foundation-heading-hyphenation.test.ts passed all 8 tests on Linux CI, and the other 679 test files passed.

…issue-1472-break-long-localized-headings-at

# Conflicts:
#	resources/packs-dev/foundation-alt/pack.json
#	resources/packs.lock.json
#	resources/packs/foundation/pack.json
The test files are type-checked without the DOM library, so the probe's
document and getComputedStyle calls go to the page as a string, as the
other browser tests do.
@gregpriday
gregpriday merged commit ef82a2f into develop Nov 28, 2026
1 of 2 checks passed
@gregpriday
gregpriday deleted the feature/issue-1472-break-long-localized-headings-at branch November 28, 2026 18:32
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.

Break long localized headings at readable word boundaries

1 participant