Skip to content

Fix "Read more" overlapping the last visible line on mobile Safari - #1739

Merged
davidmz merged 3 commits into
FreeFeed:stablefrom
deetan:fix-read-more-overlap-mobile
Sep 22, 2026
Merged

davidmz merged 3 commits into
FreeFeed:stablefrom
deetan:fix-read-more-overlap-mobile

Conversation

@deetan

@deetan deetan commented Sep 21, 2026

Copy link
Copy Markdown

Фикс бесячего read more на айфоне - картинки было-стало + клодово описание
image
image

On iOS Safari the folded post/comment text was clipped a few pixels too short: the bottom of the last visible line (descenders) was cut off, and "Read more" looked like it was overlapping the text.

Causes

  1. -4px Safari hack in Expandable. The clip height was aligned to the bottom of text rects and then reduced by 4px on Safari (UA sniffing). Modern WebKit reports tight text rects, so this always cut into the last visible line.
  2. Clip at the glyph box, not the line box. Even without the hack, the half-leading under the last line was lost, so "Read more" sat ~1px closer than the normal line spacing.
  3. overflow: clip doesn't create a BFC. In Safari the bottom margin of the hidden .post-text leaked out of the clipped container and pushed "Read more" 8px down on posts.

Changes

  • align() now snaps to the bottom of the closest line box: text rects are extended by the half-leading computed from line-height (not less than the containing block's, for inline code etc.). Works regardless of engine/font metrics, so the Safari UA sniffing is removed.
  • .clippedContent gets display: flow-root.

Result

Measured on a 375px viewport (WebKit with iPhone emulation, and Chromium), on freefeed.net/freefeed and on local posts:

line step last line → "Read more", before after
post 20px last line cut (WebKit) 20px
comment 18px last line cut (WebKit) 18px

No line crosses the clip edge in any of the 22 folded blocks on freefeed.net/freefeed, also with a stress test (line-height: 0.95, i.e. text rects taller than line boxes). Expanding works as before.

🤖 Generated with Claude Code

Den Tanaev and others added 3 commits September 21, 2026 15:24
The Expandable component aligned the clip height to the bottom of text
rects and then subtracted 4px on Safari. Modern WebKit reports tight text
rects, so that hack always cut the bottom of the last visible line and the
"Read more" button looked like it overlapped the text on mobile.

Now the clip snaps to the boundary between two adjacent lines: the middle
of their overlap (when rects are taller than the line box), or the bottom
of the upper line (when there is a gap). This works regardless of the
engine or font metrics, so the Safari UA sniffing is removed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
- Cut the folded text at the bottom of the line box, not of the glyph
  rect: extend text rects by the half-leading computed from line-height
  (not less than the containing block's one, for inline code etc.). The
  gap between the last visible line and "Read more" now equals the gap
  between text lines.
- Make the clipped container a BFC (display: flow-root). 'overflow: clip'
  doesn't create one, so in Safari the bottom margin of the hidden
  .post-text leaked out and pushed the button 8px down.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@davidmz
davidmz merged commit 071d951 into FreeFeed:stable Sep 22, 2026
1 check passed
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.

2 participants