discourse/plugins/discourse-post-voting/app/controllers
Régis HANOL fd0ddd5260
FIX: negative voter count in post voting who-voted popup (#39313)
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
2026-04-17 16:43:38 +10:00
..
post_voting FIX: negative voter count in post voting who-voted popup (#39313) 2026-04-17 16:43:38 +10:00