Skip to content

fix: mobile discussion total post count not updating on reply#4678

Merged
imorland merged 1 commit into
2.xfrom
im/mobile-scrubber-count
Jun 1, 2026
Merged

fix: mobile discussion total post count not updating on reply#4678
imorland merged 1 commit into
2.xfrom
im/mobile-scrubber-count

Conversation

@imorland
Copy link
Copy Markdown
Member

@imorland imorland commented Jun 1, 2026

Fixes #4602

The problem

On mobile, posting a reply bumps the current post number in the scrubber header but leaves the total count stale ("X of Y" — X updates, Y doesn't).

Cause

The scrubber's "viewing X of Y" label was built once as a vnode tree and then rendered in two places — the Dropdown-toggle button (the header control visible on mobile) and the <strong> inside Scrubber-info. Reusing a single vnode instance in two positions breaks Mithril's diffing, so one copy goes stale on redraw.

The current post index is force-written to the DOM via jQuery on scroll, so it always updated. The total count is only rendered through Mithril's view(), so the stale copy — the toggle button shown in the mobile header — never refreshed after a reply.

Fix

Build the label as a function that returns a fresh vnode tree per usage, so both render sites diff correctly. No behaviour change beyond correct re-rendering.

The scrubber's "viewing X of Y" label was built once as a vnode tree
and rendered in two places (the dropdown toggle and the Scrubber-info
strong). Reusing a single vnode instance in two positions breaks
Mithril's diffing, leaving one copy stale on redraw.

The current post index is force-written to the DOM via jQuery on
scroll, so it always updated; the total count is only rendered through
Mithril's view, so the stale copy (the dropdown toggle shown in the
mobile header) never refreshed after posting a reply.

Build the label as a function that returns a fresh vnode tree per
usage so both render sites diff correctly.

Fixes #4602
@imorland imorland requested a review from a team as a code owner June 1, 2026 16:37
@imorland imorland added this to the 2.0.0-rc.2 milestone Jun 1, 2026
@imorland imorland merged commit 848f4eb into 2.x Jun 1, 2026
25 checks passed
@imorland imorland deleted the im/mobile-scrubber-count branch June 1, 2026 16:50
huoxin233 added a commit to huoxin233/flarum-framework that referenced this pull request Jun 2, 2026
The scrubber's "viewing X of Y" label was built once as a vnode tree
and rendered in two places (the dropdown toggle and the Scrubber-info
strong). Reusing a single vnode instance in two positions breaks
Mithril's diffing, leaving one copy stale on redraw.

The current post index is force-written to the DOM via jQuery on
scroll, so it always updated; the total count is only rendered through
Mithril's view, so the stale copy (the dropdown toggle shown in the
mobile header) never refreshed after posting a reply.

Build the label as a function that returns a fresh vnode tree per
usage so both render sites diff correctly.

Backport fix flarum#4678

Co-authored-by: IanM <16573496+imorland@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[2.x] Mobile discussion total post count does not update on reply

1 participant