Diff view

merged…
osebo56d ago

On mobile the diff view overflows

2 repliesoldestnewest
Osebotfable-5-156d ago

Cause looks clear from the CSS: the diff <pre> lives in details.diff outside .post .body, so it never gets the overflow-x: auto that markdown code blocks get (.post .body pre). Long diff lines therefore paint past the card edge and make the whole page scroll sideways on phones.

Plan:

  1. Give details.diff pre its own scroll container (overflow-x: auto, same background/padding as body code blocks) and make sure the card/main can shrink (min-width: 0) so the pre scrolls instead of widening the layout.
  2. Verify with a static mockup of a post card at 390px and ~900px via Playwright (app can't run in the sandbox — no DB).
  3. Commit + push on thread/5538ad67.
Osebotfable-5-156d agothreadide@cf53788

Fixed and pushed on thread/5538ad67 (cf53788). CSS-only change in threadide/app/globals.css.

Root cause. In components/post.tsx the diff is rendered as <details class="diff"><pre>…</pre></details> outside .post .body. Markdown code blocks get .post .body pre { overflow-x: auto }, but the diff pre only had font-size: 12px, so long diff lines (diff --git a/… b/…, hunk headers, any line > ~50 chars) painted straight past the card and widened the whole page. On a 390px viewport the document became 1220px wide → sideways scrolling of the entire thread.

Fix. Give the diff pre its own scroll box, matching body code blocks:

details.diff { min-width: 0; }
details.diff pre { margin: 8px 0 0; padding: 10px; font-family: var(--mono); font-size: 12px; line-height: 1.45;
                   background: rgba(0,0,0,.05); border-radius: 2px; overflow-x: auto; max-width: 100%; }
details.diff code { font-family: inherit; font-size: inherit; }

Verification (static mockup linking the real globals.css, Playwright/Chromium — the app can't run in the sandbox without Postgres):

doc scrollWidthcard width
before, 390px1220px358
after, 390px390px358
after, 900px900px828

Screenshot attached is the 390px "after" — diff scrolls inside its grey box, cards stay full-width. Desktop is unchanged apart from the pre now having the same grey background/padding as other code blocks (previously it was bare text under the summary).

Note for later: anything new added to the post card outside .body (attachments, PR links, etc.) that contains white-space: pre content needs its own overflow-x: auto; .card { overflow-wrap: anywhere } only helps for normal wrapping text. Saved as a memory.

PR can be opened from https://github.com/osebo/threadide/pull/new/thread/5538ad67 when you want it merged.

Post diff view at 390px after the fix: diff scrolls inside the card, page no longer scrolls sideways
Post diff view at 390px after the fix: diff scrolls inside the card, page no longer scrolls sideways
Diff · 1 files
diff --git a/threadide/app/globals.css b/threadide/app/globals.css
--- a/threadide/app/globals.css
+++ b/threadide/app/globals.css
@@ -176,7 +176,11 @@
 details.diff summary { cursor: pointer; color: var(--muted); font-size: 13px; font-family: var(--sans); }
-details.diff pre { font-size: 12px; }
+/* The diff <pre> sits outside .body, so it needs its own scroll box: long diff lines scroll inside the card
+   instead of pushing the whole page sideways on phones. min-width:0 lets the card shrink below the pre's content width. */
+details.diff { min-width: 0; }
+details.diff pre { margin: 8px 0 0; padding: 10px; font-family: var(--mono); font-size: 12px; line-height: 1.45; background: rgba(0,0,0,.05); border-radius: 2px; overflow-x: auto; max-width: 100%; }
+details.diff code { font-family: inherit; font-size: inherit; }
 .refs { margin-top: 8px; font-size: 12px; color: var(--muted); }