fix(url-preview): show scroll arrows only when content overflows#301
Merged
Just-Insane merged 3 commits intodevfrom Mar 16, 2026
Merged
fix(url-preview): show scroll arrows only when content overflows#301Just-Insane merged 3 commits intodevfrom
Just-Insane merged 3 commits intodevfrom
Conversation
…surement for arrows The old code used IntersectionObserver anchors to determine whether scroll arrows should be shown. This caused false positives in two scenarios: 1. When a UrlPreviewCard renders null (fetch error), the empty anchor div was sometimes not detected as intersecting, leaving a stale arrow visible. 2. When loading (Spinner makes card 400px wide), the IO would mark the front anchor as not visible, showing the arrow; after load failure the arrow stayed stuck. Replace with direct scrollWidth/clientWidth measurement via ResizeObserver (fires on container and content resize) plus a scroll event listener. Arrows now only appear when the horizontal scroll area actually has overflowed content. Fixes #220
Contributor
Deploying with
|
| Status | Preview URL | Commit | Alias | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! | https://pr-301-sable.raspy-dream-bb1d.workers.dev | f7afb8d | pr-301 |
Mon, 16 Mar 2026 19:26:53 GMT |
dozro
approved these changes
Mar 16, 2026
7w1
approved these changes
Mar 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #220 — URL preview cards showed orange scroll arrows even when there was no content to scroll.
Root cause
The previous implementation used
IntersectionObserverto watch 0×0 anchor divs at each end of the scroll container. These anchors triggered false positives during initial load (before images were sized) and when the container was just barely fitting its content, so arrows appeared even when scrolling wasn't possible.Fix
Replaced the IntersectionObserver approach with:
scrollevent listener on the container that readsscrollLeft,scrollWidth, andclientWidthResizeObserveron both the scroll container and its inner content boxArrows now only render when
scrollWidth > clientWidth, i.e. when there is actual overflow to scroll through. TheupdateArrows()function runs on mount, scroll, and any resize of the container or its contents.