fix: _loadOlderMessages scrolls to bottom instead of preserving position#1219
fix: _loadOlderMessages scrolls to bottom instead of preserving position#1219jasonjcwu wants to merge 1 commit intonesquena:masterfrom
Conversation
When _loadOlderMessages prepends older messages, the viewport snaps
to the bottom instead of staying where the user was.
Two bugs compounding:
1. Wrong scrollable container. Code used `$("msgInner")` for scrollHeight
and scrollTop, but #msgInner has no overflow-y — it is a flex column.
The actual scrollable container is #messages (`.messages{overflow-y:auto}`).
Setting msgInner.scrollTop was silently ignored.
2. renderMessages calls scrollToBottom at the end (ui.js:2552),
which unconditionally scrolls #messages to the bottom and sets
_scrollPinned=true. Since bug nesquena#1 made the scroll-restore a no-op,
the page landed at the bottom every time.
Fix:
- Changed scroll restore target from `$("msgInner")` to `$("messages")`.
- Reset _scrollPinned = false after restoring the user position,
so scrollToBottom does not re-fire on next tick.
|
Great bug diagnosis, @jasonjcwu! The two-bug root cause analysis is exactly right:
The fix is minimal and surgical: change the scroll container reference to One thing to verify: after setting The test coverage in Clean fix overall — thanks for tracking this down! |
|
When Root cause (two bugs compounding)1. Wrong scrollable container. The code used 2. Fix
Safety analysisAll code paths that read
No unwanted scrolls are triggered. Tests2 new tests in
35/35 tests passing. |
|
Thanks for the thorough follow-up, @jasonjcwu! The detailed root cause analysis with the two-bug breakdown (wrong container + The fixes are minimal and targeted:
The safety analysis confirms no downstream The 2 new tests in This looks ready for maintainer review and merge. Clean fix with solid coverage. 🎉 |
|
Merged in v0.50.237 via #1243. Thank you @jasonjcwu! 🎉 |
When _loadOlderMessages prepends older messages, the viewport snaps to the bottom instead of staying where the user was.
Two bugs compounding:
$("msgInner")for scrollHeight and scrollTop, but #msgInner has no overflow-y — it is a flex column. The actual scrollable container is #messages (.messages{overflow-y:auto}). Setting msgInner.scrollTop was silently ignored.Fix:
$("msgInner")to$("messages").