Skip to content

fix(web): keep the comments scrolled in place while their images load - #31

Merged
cornedor merged 1 commit into
mainfrom
comments-scroll-images
Nov 20, 2026
Merged

cornedor merged 1 commit into
mainfrom
comments-scroll-images

Conversation

@cornedor

Copy link
Copy Markdown
Owner

Opening the Comments tab scrolls to the latest comment (or centres a linked one), but it only re-applied that for about 20 frames. Lazy-loaded images in comments have no reserved height, so one that arrived later made its comment taller and pushed the end away. Cached images didn't, which made it inconsistent.

Both loops are replaced by one hold that re-applies the position whenever the comment list changes height (ResizeObserver). It lets go as soon as the user scrolls, clicks or presses a key, or leaves the tab.

While the hold is active and untouched, a newly arriving comment also scrolls to the end.

Test: new e2e test with three comments whose images take 800 ms to load. It passes with the fix and ends 947 px from the end when the hold is cut off after 20 frames. The 20 tests in issue.spec.mjs pass. The ?comment= path uses the same hold but has no test of its own.

@cornedor
cornedor merged commit 54e97c2 into main Nov 20, 2026
7 checks passed
@cornedor
cornedor deleted the comments-scroll-images branch November 20, 2026 10:23
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.

1 participant