fix: mobile discussion total post count not updating on reply#4678
Merged
Conversation
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
9 tasks
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>
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-togglebutton (the header control visible on mobile) and the<strong>insideScrubber-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.