Avoid orphaned punctuation using non-breaking whitespace#11929
Merged
Conversation
changelog: User-Facing Improvements, Content Legibility, Avoid orphaned punctuation using non-breaking whitespace
aduth
commented
Feb 27, 2025
Comment on lines
-52
to
+62
| <br> <%= t('shared.banner.secure_description_html', lock_icon: render('shared/banner-lock-icon')) %> | ||
| <br> | ||
| <%= t( | ||
| 'shared.banner.secure_description_html', | ||
| lock_icon: image_tag( | ||
| asset_path('lock.svg'), | ||
| width: 9, | ||
| height: 12, | ||
| class: 'usa-banner__lock-image', | ||
| alt: t('shared.banner.lock_description'), | ||
| ), | ||
| ) %> |
Contributor
Author
There was a problem hiding this comment.
This change addresses an edge-case where we previously relied on HTML whitespace collapsing with the space around the embedded lock and the final newline of the lock icon partial file. Using non-breaking spaces, the collapse doesn't occur, and therefore without these changes there's a slight increase in the amount of space to the right of the icon. The fix here inlines the icon rendering to avoid the trailing newline from the partial.
| Before | After |
|---|---|
![]() |
![]() |
It might also have a slight performance benefit of avoiding another partial load, and avoids some indirection for a partial that's not otherwise reused outside the banner.
mitchellhenke
approved these changes
Feb 27, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


🛠 Summary of changes
Enforces consistency of using non-breaking spaces within paired punctuation to avoid orphaned punctuation when line breaks occur, and fixes existing issues. It also adds French quotation characters ("guillemets": « ») as expected punctuation pairs.
The intent is to avoid the sorts of issues observed in #11911, consistently requiring that non-breaking spaces be used whenever there is whitespace within paired punctuation (parentheses, quotes, etc.).
Example (fixed in #11911):
📜 Testing Plan
Verify there's no regressions in the affected text. For example, ensure that the expanded banner text shows the lock icon within parentheses with whitespace.