Skip to content

Conversation

@jonathanhefner
Copy link
Member

When wrapping text, Safari and Chrome do not consider / nor : as word break characters. Firefox considers / as a word break character but not :. This can lead to horizontal overflow issues with long file paths and module names on mobile.

This commit adds a full_name helper to insert word-break opportunities into file paths and module names. It also revises the link_to helper to do the same when given an RDoc::CodeObject. The helpers insert <wbr> tags which tell the browser that the text can be wrapped at that point.

Before (Before) After
before1a before1b after1
before2a before2b after2

(The above screenshots were taken using Chrome's developer tools on desktop. The "Before" screenshots may vary between different browsers.)

When wrapping text, Safari and Chrome do not consider `/` nor `:` as
word break characters.  Firefox considers `/` as a word break character
but not `:`.  This can lead to horizontal overflow issues with long file
paths and module names on mobile.

This commit adds a `full_name` helper to insert word-break opportunities
into file paths and module names.  It also revises the `link_to` helper
to do the same when given an `RDoc::CodeObject`.  The helpers insert
`<wbr>` tags which tell the browser that the text can be wrapped at that
point.
@jonathanhefner jonathanhefner merged commit 864444f into rails:main Aug 5, 2023
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.

1 participant