Skip to content

fix: overflow with long words - #1215

Merged
maxelkins merged 9 commits into
mainfrom
fix-long-words-creating-overflow
Jun 19, 2025
Merged

fix: overflow with long words#1215
maxelkins merged 9 commits into
mainfrom
fix-long-words-creating-overflow

Conversation

@maxelkins

@maxelkins maxelkins commented Jun 13, 2025

Copy link
Copy Markdown
Contributor

Overview

This PR aims to solve this problem globally rather than just in the 1 instance spotted as I suspect this is happen frequently with translations.

  • Adds hyphenation globally to elements within the editor wc.
  • Excludes elements that commonly avoid hyphenation.

If we feel this is to aggressive since it does hyphen instead of wrapping nomally in some instances, we could just apply it to the info-panel in the sidebar.

Additional notes

Result

Note to preview this you must manually set the html lang to "de" since hyphenation relies on the browser implementation and our demo language (XX-xx) is not a real locale

Useful resources

Suggested solutions

Option 1 (currently implemented)

  • Add hyphen: auto globally (with exceptions)
  • Progresively enchance with hyphen-limit-chars (mdn ref) to avoid over hyphenating
  • Soft hyphens \u00AD can be used by the translation team to encourage preffered hyphenations

Pros:

  • Covers all languages and probably majority of problems
  • With hyphens we should avoid content not being visible due to overflow
  • Browsers have hyphen dictionaries for different locales so this should be locale sensitive
  • hyphen-limit-chars is an easy progressive enchancement, as the experience is not broken (although not ideal) without it.
  • Does not require any extra effort from us or translation team to maintain.

Cons:

  • Without hyphenate-limit-chars the browser seems to overly hyphen rather than wrapping text when possible, which could argueably be hard to read.
  • Limited support for hyphen-limit-chars
    • No Safari support, newly supported in Firefox

Examples:

Auto inserted hyphens (hyphen limit could still be adjusted):

Image

Without hyphen-limit-chars (en):

  • As you can see it over hyphenates when it could just wrap the words

Image

with hyphen-limit-chars(en):

Image

Option 2

  • Enable hyphens: manual. This enables the translation team to manually insert (soft) hyphens to enourage words to break in ideal positions when they are long.
  • overflow-wrap: break-word; can be used as a fallback to wrap words (without hyphens) if manual soft hyphens have not been set.

Pros:

  • Avoids overly hyphenating
  • Accounts for cases where translation team has not set soft hyphens

Cons:

  • Heavily relys on translation team (or us).
  • Without a visual reference to the UI when translating too it might not be obvious when soft hyphens need to be applied.
  • The fallback of overflow-wrap: break-word does NOT insert hyphens which can be confusing and hard to read.

Example:

Image

Image

Option 3

  • We manually fix issues like this on a case by case basis for every language.

Pros:

  • Quick individually to resolve issues.

Cons:

  • Long term time consuming
  • Increased tech/design/language debt

@maxelkins maxelkins linked an issue Jun 13, 2025 that may be closed by this pull request
@maxelkins
maxelkins temporarily deployed to previews/1215/merge June 13, 2025 16:00 — with GitHub Actions Inactive
@maxelkins
maxelkins marked this pull request as draft June 13, 2025 16:08
@maxelkins
maxelkins marked this pull request as ready for review June 13, 2025 16:12
@maxelkins

Copy link
Copy Markdown
Contributor Author

@maxelkins
maxelkins temporarily deployed to previews/1215/merge June 17, 2025 14:12 — with GitHub Actions Inactive
By setting `scroll` rather than `auto` scrollbar is shown even when there is no overflow
@maxelkins
maxelkins temporarily deployed to previews/1215/merge June 17, 2025 14:37 — with GitHub Actions Inactive

@adrian-rpf adrian-rpf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maxelkins Changes make sense based on your thread with @loiswells97

What testing has been done on:

  • Different code projects
  • Browser viewport sizes?

@adrian-rpf adrian-rpf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go to go

@loiswells97 loiswells97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it's missing a changelog update. Looks great though 👍

@maxelkins
maxelkins temporarily deployed to previews/1215/merge June 18, 2025 12:50 — with GitHub Actions Inactive
@maxelkins
maxelkins temporarily deployed to previews/1215/merge June 18, 2025 15:59 — with GitHub Actions Inactive
Comment thread src/assets/stylesheets/InternalStyles.scss
@maxelkins
maxelkins requested a review from loiswells97 June 18, 2025 16:28
@maxelkins
maxelkins enabled auto-merge (squash) June 18, 2025 16:31
@maxelkins
maxelkins disabled auto-merge June 18, 2025 21:19
@maxelkins

maxelkins commented Jun 19, 2025

Copy link
Copy Markdown
Contributor Author

Further examples

Tested with small size sizebar with some instructions (best example of long form content in sidebar). Plus with some code just to make sure it isnt doing anything funky.

I'd like to test with the projects site projects but this is proving tricky.

Although not perfect, I'd prefer only to hyphenate when words can't be wrapped (such as this proposal, ths currently isn't possible and this solution at least covers more problems with localisation.

We can always tune the hyphen-limt-chars too

Note the line height issues on viewing instructions content are not related to this.

Screenshot 2025-06-19 at 12 01 39@2x

Screenshot 2025-06-19 at 12 05 10@2x

Screenshot 2025-06-19 at 12 07 43@2x

Screenshot 2025-06-19 at 12 08 31@2x

@loiswells97 loiswells97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! 🎉

@maxelkins
maxelkins merged commit b7f0107 into main Jun 19, 2025
8 checks passed
@maxelkins
maxelkins deleted the fix-long-words-creating-overflow branch June 19, 2025 12:56
@jamiebenstead jamiebenstead mentioned this pull request Jul 22, 2025
jamiebenstead added a commit that referenced this pull request Jul 22, 2025
## [0.30.2] - 2025-07-22

### Fixed

- Styling issue preventing scrolling in the sidebar (#1216)
- Styling issue on status bar on mobile (#1217)
- Change tab `block-size` to `min-block-size` to allow for height
increase when text wraps (#1219)
- Changed `SkulptRunner.jsx` implementation of hiding elements to use
`display: none` rather than `block-size: 0` (#1219)
- Enabled `hyphens: auto` globally (with exceptions) to prevent overflow
with longer words (#1215)
- Removed fixed size from `ProjectBar` to prevent overflow when text
wraps (#1221)
- Added missing translation strings (#1222)
- Changed `colour_raw` to now correctly return a 4-tuple (R, G, B,
Clear) in simulation

### Changed

- Improved status bar styling (#1221)
- Added horizontal scrollbar to editor (#1228)
- Add theme for scrollbars (#1233)
jamiebenstead added a commit that referenced this pull request Jul 28, 2025
## [0.30.2] - 2025-07-22

### Fixed

- Styling issue preventing scrolling in the sidebar (#1216)
- Styling issue on status bar on mobile (#1217)
- Change tab `block-size` to `min-block-size` to allow for height
increase when text wraps (#1219)
- Changed `SkulptRunner.jsx` implementation of hiding elements to use
`display: none` rather than `block-size: 0` (#1219)
- Enabled `hyphens: auto` globally (with exceptions) to prevent overflow
with longer words (#1215)
- Removed fixed size from `ProjectBar` to prevent overflow when text
wraps (#1221)
- Added missing translation strings (#1222)
- Changed `colour_raw` to now correctly return a 4-tuple (R, G, B,
Clear) in simulation

### Changed

- Improved status bar styling (#1221)
- Added horizontal scrollbar to editor (#1228)
- Add theme for scrollbars (#1233)
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.

fix: overflow with long words

3 participants