Skip to content

Keep the attendee chat pinned to the newest post - #268

Open
junkerderprovinz wants to merge 2 commits into
ClaperCo:devfrom
junkerderprovinz:fix/attendee-chat-autoscroll
Open

junkerderprovinz wants to merge 2 commits into
ClaperCo:devfrom
junkerderprovinz:fix/attendee-chat-autoscroll

Conversation

@junkerderprovinz

Copy link
Copy Markdown
Contributor

Fixes #264.

The attendee room already follows new posts while the reader is at the bottom (RoomFeed on #chat-feed), but it can stop without the reader scrolling. The hook measured the distance to the bottom on every patch, so when the feed got shorter (the focus slot or captions taking space) or the newest post grew with a moderator reply, a reader who never scrolled counted as scrolled up, and every later post only showed the "new messages" chip. Busy rooms can also lose it another way: the hook's own smooth scroll fires scroll events, and a post that arrived mid-animation switched following off for good.

The hook now keeps a follow flag. Only scrolling up clears it, and being within 48 px of the bottom sets it again, also after a resize or a patch that comes without a scroll event. It re-pins when the feed grows or gets shorter (a ResizeObserver), and leaves the position alone on patches that don't make the feed taller, such as reaction counts or caption updates.

There are two commits. The first moves the unchanged hook into assets/js/room_feed.mjs, following date_time_local.mjs, so it can be tested. The second changes the behaviour and adds assets/test/room_feed_hook_test.mjs. The test mock plays smooth scrolls over several frames with scroll events in between, because that is where the race happens.

I checked it in Chromium against a running server: two posts 45 ms apart, a reply on the newest post, a shrinking feed, and a reaction while the reader sits 30 px above the bottom. The old hook reproduced each problem; the new one follows, or stays put in the reaction case. Chromium ignores wheel input during a programmatic smooth scroll, so a reader scrolling up mid-animation is only covered by the unit test. There are no Elixir changes.

This shouldn't conflict with #251. Collapsing and expanding its chat panel resizes the feed, which the observer picks up.

@alxlion alxlion added the enhancement New feature or request label Oct 13, 2026
junkerderprovinz added 2 commits November 18, 2026 21:02
The feed measured the distance to the bottom on every patch to decide
whether to follow a new post. When the panel got shorter (focus slot,
captions) or the newest post grew with a reply, a reader who never
scrolled counted as scrolled up and the feed stopped following.

Keep a follow flag instead that only the reader scrolling up clears, so
neither the feed's own smooth scroll nor a post arriving during it turns
following off. Re-pin when the feed grows or gets shorter, and leave the
position alone on patches that do not make it taller.
@junkerderprovinz
junkerderprovinz force-pushed the fix/attendee-chat-autoscroll branch from 50cbbb4 to 4696cbd Compare November 18, 2026 20:02

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Autoscroll of chat in Attendees room

2 participants