NodeBB 4.16.0, Harmony.
Users kept reporting that short topics open from the first post after a new reply, instead of at the new post. I traced it to navigator.update() in public/src/modules/navigator.js.
When the whole topic fits on the screen (no scrolling), both conditions are true:
atTop: scrollTop === 0 and the first post is index 0
nearBottom: the bottom is visible and the last post is index count - 1
atTop is checked first, so newIndex is 1. Topic.navigatorCallback(1, count) then:
doesn't advance the bookmark (index 1 is not > bookmarkThreshold)
doesn't hit the "index >= elementCount" read path
The topic is still marked read when it loads, but the bookmark stays behind. After the next reply the topic list links to the old bookmark (or none), so it opens from the start.
To reproduce: log in, open a topic with 2-4 short posts that fits on the screen without scrolling, don't scroll. GET /api/topic/: bookmark is still null. Add a reply from another account, then open the topic from /recent or /unread: it starts at post 1.
Suggested fix: when the whole topic is visible, treat it as being at the bottom:
if (nearBottom) {
newIndex = count;
} else if (atTop) {
newIndex = 1;
}
I'm handling it with a small client-side workaround for now: when the last post is loaded and the page is at the bottom, or not scrollable, it emits topics.bookmark with postcount. It would be better fixed in core.
@julian @baris