mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-02 06:48:58 +08:00
When a post in a post-voting topic had both upvotes and downvotes,
clicking the vote count to view the voter list could display a "and -N
more users..." label with a negative number.
The root cause was that `calcRemainingCount` used the post's
`post_voting_vote_count` (the net score, i.e. upvotes − downvotes)
instead of the actual total number of voters. With 2 upvotes and 3
downvotes, net score is −1, minus 5 displayed voters = −6. Since −6 is
truthy in JS, the label would render.
The fix adds `total_voters_count` to the `/post_voting/voters` JSON
response so the client has a reliable total to subtract from. The
component now stores this value and uses it in `calcRemainingCount` with
a `Math.max(0, ...)` guard.
Also removes a no-op `{{#if whoVoted}}` template guard that referenced
the imported function (always truthy) instead of a result, and fixes the
voter popup z-index so it renders above subsequent posts.
Ref - t/181822
|
||
|---|---|---|
| .. | ||
| comments_controller.rb | ||
| votes_controller.rb | ||