Today I saw this React hook (see photo) get shared on birdsite. It enables one to “automatically scroll down when new messages arrive in a chat”.

While it might work, you could — and should — use this little bit of CSS instead:

```
.log {
scroll-snap-type: y proximity;
align-content: end;
}
.log::after {
display: block;
content: "";
scroll-snap-align: end;
}
```

“… remains snapped to the bottom …unless the user has scrolled away from that edge” — https://drafts.csswg.org/css-scroll-snap/#example-d0a2d86f

CSS Scroll Snap Module Level 1

@bramus I had no idea this was possible but was curious how it works, so I made a quick #codepen of this idea: https://codepen.io/mgrubinger/pen/LYKQaQz

I love how simple (and reliable) this #css solution is!

Stay at Bottom of Appending List using CSS Scroll Snapping

...

@grooovinger
Hhm it seems it does not work with my Android Firefox.
@bramus

#codepen #css

@chfkch @bramus apparently it's not supported by firefox yet.
@grooovinger @chfkch Yeah, noticed that too … filing a bug as that should actually work.

@grooovinger @chfkch Bug Report: https://bugzilla.mozilla.org/show_bug.cgi?id=1914178

Workaround: instead of snapping generated content, you can snap the `:last-child`.

1914178 - scroll-snap not working on generated content

UNCONFIRMED (nobody) in Core - Layout: Scrolling and Overflow. Last updated 2024-08-21.