Fix it so long strings don't cause the page to get wider on mobile
Problem
https://openlibrary.org/help/faq/editing
Probably one line of CSS we need to update.
Reproducing the bug
- Open https://openlibrary.org/help/faq/editing on a phone, or at a 375px-wide viewport in devtools
- Scroll down to the list of example work URLs
- Expected behavior: long strings wrap inside the content column, and the page doesn't scroll sideways.
- Actual behavior:
Moon_is_Down_Of_Mice_and_Men_Pearl_Red_Pony_Tortilla…runs off the edge, which makes the whole page (header included) wider than the viewport.
Context
- Browser (Chrome, Safari, Firefox, etc): any (mobile)
- OS (Windows, Mac, etc):
- Logged in (Y/N):
- Environment (prod, dev, local): prod
Breakdown
Implementation Details (for maintainers)
Cause. Two things combine:
- The only wrap rule for wiki pages is
div#contentBody p a { word-wrap: break-word; }, so it only covers links inside paragraphs. Plain text, list items, headings, etc. don't wrap. - On this page, the URL
https://openlibrary.org/works/OL23185W/The_Short_Novels_of_John_Steinbeck_(Cannery_Row_…contains parentheses, which break the markdown link. The link ends partway through, and the rest renders as unlinked plain text. Rule 1 doesn't cover plain text, so it overflows.
Fix. Make wrapping apply to the whole content container instead of just p a:
div.contentBody,
div#contentBody {
overflow-wrap: break-word;
}
Then remove the now-redundant p a rule. break-word only breaks a string that can't fit on its own line, so normal text on other pages is unaffected.
Requirements Checklist
- [ ] Replace the
div#contentBody p a/div.contentBody p arule instatic/css/layout/index.csswithoverflow-wrap: break-wordondiv#contentBody, div.contentBody - [ ] Verify at a 375px viewport that
/help/faq/editingno longer scrolls horizontally (include before/after screenshots in the PR) - [ ] Spot-check a few other pages that use the same template (
/about,/help, another/help/faq/*page) for regressions - [ ] (Maintainer, separate from the PR) Fix the malformed links on
/help/faq/editingitself (theOL23185WandOL17592217Wexamples) by editing the page source via?m=edit
Related files
static/css/layout/index.css(the#contentBodyrules, ~L55-66)openlibrary/templates/type/page/view.html(wraps wiki page bodies in#contentBody)
Stakeholders
- @lokesh
Instructions for Contributors
- Please run these commands to ensure your repository is up to date before creating a new branch to work on this issue and each time after pushing code to Github, because the pre-commit bot may add commits to your PRs upstream.
⚠️ Contributors, this issue will be ready to work on once:
- [ ] Triage — maintainers will add
Priority: *andLead: @* - [ ] Needs: Breakdown — issue lacks concrete implementation steps
Context
Codebase research points to a couple of concrete, related gaps rather than a single "one line of CSS" fix:
/help/faq/editingis rendered by the generic wiki-page template, whose body is wrapped in<div id="contentBody" class="markdown-content">: https://github.com/internetarchive/openlibrary/blob/9827e3bb53ba712fe86324014d4424a5f7a701ca/openlibrary/templates/type/page/view.html L44-L50- The only wrapping rule scoped to that container only applies to links inside paragraphs, not to plain text, headings, list items, or inline code: https://github.com/internetarchive/openlibrary/blob/9827e3bb53ba712fe86324014d4424a5f7a701ca/static/css/layout/index.css L61-L65
static/css/markdown.css, which styles.markdown-content, has nooverflow-wrap/word-breakrule at all (list, blockquote, andhrstyling only): https://github.com/internetarchive/openlibrary/blob/9827e3bb53ba712fe86324014d4424a5f7a701ca/static/css/markdown.css L1-L42- Elsewhere in the codebase this exact class of bug has been fixed with
overflow-wrap: break-word/anywherescoped to the specific container (e.g.static/css/components/work-title-and-author.css:19,static/css/components/mybooks-list.css:44,static/css/components/tagging-menu.css:170), which is a reasonable pattern to follow here. - This is not the first mobile-overflow bug on this exact page: issue 13074 ("Help page /help/faq/editing renders orphaned markdown reference-link definitions as visible junk") was a different root cause (a markdown-preprocessor bug, already fixed) but confirms this page has a history of rendering edge cases on long content.
- Related but distinct prior bug: issue 4974 ("Long string in list description doesn't wrap", closed) — same underlying class of bug (long unbroken string not wrapping) in a different component.
I could not confirm the exact string in the screenshot that triggers the overflow (no browser access in this environment), so the specific selector to patch isn't 100% pinned down — see open question below.
Issue Assessment
Open questions
- What is the specific long string in the screenshot — a long URL rendered as plain text, an inline code span, or something else? Knowing this determines whether the fix belongs in
markdown.css(general.markdown-contentrule) or needs to also touchstatic/css/layout/index.css's#contentBodyrules. - Is this specific to
/help/faq/editing, or does it reproduce on other markdown/wiki-style pages (e.g. other/help/*or/aboutpages) that render through the sametype/page/view.htmltemplate? The title says "the page" generically but only one page/screenshot is referenced.
Action items
- [ ] Fill in Reproducing the bug (steps, expected vs. actual behavior) and Context (browser, OS, logged in) — currently template placeholders, left blank.
- [ ] Confirm whether the fix should be scoped narrowly (
.markdown-content) or should also cover the#contentBody p a-only rule inlayout/index.css, since a broader fix could affect more pages than intended.
Suggested breakdown
- [ ] Reproduce on mobile viewport and identify the exact element/string overflowing the layout.
- [ ] Add an
overflow-wrap/word-breakrule scoped to.markdown-content(and/or broaden the#contentBodyrule instatic/css/layout/index.css) to cover plain text, not just links. - [ ] Verify no regression on other pages that share
type/page/view.html(e.g./about, other/help/*pages,/collections).
This looks like it could be a Good First Issue once the exact offending element is pinned down and the acceptance criteria (repro steps, expected/actual) are filled in — the likely fix is a scoped CSS rule, but I'm not applying the label until scope is confirmed.
🔔 Stakeholders
@lokesh — front-end/CSS design-system lead; the related prior bug on this same page (issue 13074) was also tagged to you, and this fix lives in markdown.css/layout/index.css, both front-end/CSS surfaces.
Full triage checklist
- [x] Triage — labels applied (
Affects: UI,Module: CSS,Affects: Mobile/Responsive);Needs: Triage/Needs: Leadleft in place pending maintainer review - [ ] Problem / opportunity — a screenshot is provided but no description of the specific string/element or which page(s) are affected beyond one example
- [ ] Scope — unclear if this is scoped to
/help/faq/editingor is a broader "any long string on mobile" issue - [ ] Justification — no stated impact beyond the screenshot
- [ ] Success & testing criteria — not defined (Reproducing the bug / Expected / Actual left blank)
- [ ] Proposal & breakdown — only a speculative guess ("probably one line of CSS"); no concrete plan or checklist
- [ ] If bug: environment & repro steps — Browser/OS/Logged-in fields left blank; only Environment (prod) filled in
- [x] Risks, concerns, open questions — surfaced above
- [x] Richy context — relevant code and related issues reviewed; no exact duplicate found
- [x] References — screenshot present
[!NOTE] This comment was automatically generated by Richy (https://github.com/internetarchive/openlibrary/blob/master/.github/workflows/issue_enrichment.md), Open Library's issue enrichment assistant, on behalf of @mekarpeles. This is NOT a sign-off. This issue needs lead review before work begins.
Hi @RayBB I would like to take up this issue! Seems like a good start for my first contribution.
Hi @Prabh0608, it's yours! Thanks for picking it up.
Here's what I found while looking into it. The wiki page content sits inside #contentBody, and the only wrapping rule there (in static/css/layout/index.css) targets links inside paragraphs (p a). On this page, one of the long example URLs has broken markdown, so part of it renders as plain text. That rule doesn't cover plain text, so the string runs off the edge.
One option is to move overflow-wrap: break-word up to the container so it covers all of the content, not just links. Feel free to take a different approach if you find something better, though.
Before you open the PR, please:
- Test at a mobile width (a real phone, or ~375px in devtools)
- Post before/after screenshots of
/help/faq/editingin the PR - Spot-check another page or two that use the same layout (e.g.
/about) to make sure nothing else changed
Let me know if you get stuck!
Thanks @lokesh! I’ve followed the developer handbook and got the local setup running smoothly. The only issue is that clicking on "Help Center" leads to a 404 Not Found error. Am I missing a configuration or a step?
Problem
https://openlibrary.org/help/faq/editing
Probably one line of CSS we need to update.
### Reproducing the bug 1. Open https://openlibrary.org/help/faq/editing on a phone, or at a 375px-wide viewport in devtools 2. Scroll down to the list of example work URLs
- Expected behavior: long strings wrap inside the content column, and the page doesn't scroll sideways.
- Actual behavior:
Moon_is_Down_Of_Mice_and_Men_Pearl_Red_Pony_Tortilla…runs off the edge, which makes the whole page (header included) wider than the viewport.Context
- Browser (Chrome, Safari, Firefox, etc): any (mobile)
- OS (Windows, Mac, etc):
- Logged in (Y/N):
- Environment (prod, dev, local): prod
Breakdown
Implementation Details (for maintainers) Cause. Two things combine:
- The only wrap rule for wiki pages is
div#contentBody p a { word-wrap: break-word; }, so it only covers links inside paragraphs. Plain text, list items, headings, etc. don't wrap.- On this page, the URL
https://openlibrary.org/works/OL23185W/The_Short_Novels_of_John_Steinbeck_(Cannery_Row_…contains parentheses, which break the markdown link. The link ends partway through, and the rest renders as unlinked plain text. Rule 1 doesn't cover plain text, so it overflows.Fix. Make wrapping apply to the whole content container instead of just
p a:div.contentBody, div#contentBody { overflow-wrap: break-word; } Then remove the now-redundant
p arule.break-wordonly breaks a string that can't fit on its own line, so normal text on other pages is unaffected.Requirements Checklist
- [ ] Replace the
div#contentBody p a/div.contentBody p arule instatic/css/layout/index.csswithoverflow-wrap: break-wordondiv#contentBody, div.contentBody[ ] Verify at a 375px viewport that/help/faq/editingno longer scrolls horizontally (include before/after screenshots in the PR)[ ] Spot-check a few other pages that use the same template (/about,/help, another/help/faq/*page) for regressions[ ] (Maintainer, separate from the PR) Fix the malformed links on/help/faq/editingitself (theOL23185WandOL17592217Wexamples) by editing the page source via?m=editRelated files
static/css/layout/index.css(the#contentBodyrules, ~L55-66)openlibrary/templates/type/page/view.html(wraps wiki page bodies in#contentBody)Stakeholders
Instructions for Contributors
- Please run these commands to ensure your repository is up to date before creating a new branch to work on this issue and each time after pushing code to Github, because the pre-commit bot may add commits to your PRs upstream.
Hii, Actually i have got a better approach for this. Kindly let me solve this issue and create a PR for it.
Hi @iamtanmaybaranwal I am currently working on this and trying to make my first contribution through this issue! Hope you understand but i am open to know about your approach and also do you know anything about the 404 not found error i mentioned above? I am happy to discuss about it!
I came across issue #1864 while going through documentaion, which addresses this problem. However, the reference links provided in that issue are no longer working. Based on the discussion, I tried using scripts/copydocs.py with the --src and --dest flags. Doing this resolved the 404 error, but now the page displays 'No translations found.' How should I proceed @lokesh @RayBB @mekarpeles ?
@Prabh0608
Hi @Prabh0608 You're not missing anything. The help pages are wiki content stored on openlibrary.org, not in the code, so they don't exist on a fresh local install.
You don't need that page to test this, though. The bug is in CSS shared by every wiki page, so you can reproduce it on any one:
- Log in locally as
openlibrary/openlibrary - Go to something like
http://localhost:8080/test-wrap?m=editand create a page - Paste in a long unbroken string, e.g.
The_Short_Novels_of_John_Steinbeck_(Cannery_Row_Moon_is_Down_Of_Mice_and_Men_Pearl_Red_Pony_Tortilla_Flat), both as plain text and inside a list item - Save it and view it at ~375px wide in devtools
Before/after screenshots of that test page are fine for the PR. If you'd like to try the real content, copydocs.py can pull /help/faq/editing straight from openlibrary.org, but it isn't required.
### Reproducing the bug
1. Open https://openlibrary.org/help/faq/editing on a phone, or at a 375px-wide viewport in devtools
2. Scroll down to the list of example work URLs