[1.x] fix: mobile discussion total post count not updating on reply#4684
Open
huoxin233 wants to merge 1 commit into
Open
[1.x] fix: mobile discussion total post count not updating on reply#4684huoxin233 wants to merge 1 commit into
huoxin233 wants to merge 1 commit into
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. Backport fix flarum#4678 Co-authored-by: IanM <16573496+imorland@users.noreply.github.com>
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
Same issue exits in 1.x also
Backport fix #4678 to 1.x
Changes proposed in this pull request:
Same as 2.x
This PR fixes a UI regression in the
PostStreamScrubbercomponent where the total post count in the mobile discussion header fails to update when a user posts a reply.Previously, the
viewingtranslation string was instantiated once as a static array of VNodes and injected into two distinct DOM locations (the dropdown header button and the scrubber handle). Because Mithril 2 does not support reusing VNode object references across multiple locations, thevnode.dompointers for the header were silently overwritten by the scrubber handle. This caused subsequentm.redraw()cycles to update the total count and pluralization natively in the scrubber handle, but completely ignore the header button.By wrapping the translation output in a
viewing()closure function and calling{viewing()}in both JSX locations, we ensure fresh, independent VNodes are generated. This allows Mithril to accurately track and natively update both DOM elements during standard redraw cycles.Reviewers should focus on:
Screenshot
Before:
PixPin_2026-06-02_18-37-02.mp4
After:
PixPin_2026-06-02_18-39-59.mp4
Necessity
Confirmed
composer test).Required changes: