Continuing the discussion from Voting plugin — hiding "empty" votes in the topic list?:
If you have “simple” tag display enabled, and the post has at least one tag but no votes, the tag list will be followed by a comma.
A minor bug has been reported in hiding “0 votes” from the topic list in the Discourse voting plugin. When a post has at least one tag but no votes and “simple” tag display is enabled, a trailing comma appears after the tag list. This is because the hidden vote count is still considered a child element. awesomerobot suggests that this issue can be handled with CSS, and provides a workaround using the :has pseudo-class. The workaround hides the comma on the second-to-last tag when the vote count is 0. However, it’s recommended to add a proper “hide 0 votes on topic list” option to the plugin to avoid the issue entirely.
Continuing the discussion from Voting plugin — hiding "empty" votes in the topic list?:
If you have “simple” tag display enabled, and the post has at least one tag but no votes, the tag list will be followed by a comma.
Because:
.discourse-tags .discourse-tag.simple:not(:last-child)::after, .list-tags .discourse-tag.simple:not(:last-child)::after, .search-category .discourse-tag.simple:not(:last-child)::after {
content: ", ";
margin-left: 1px;
}
and the vote count is still a child even when hidden, I guess.
The easiest workaround is to not use “simple”, of course.
4 posts were split to a new topic: How to hide 0 votes?
Right, when hidden with CSS it’s still counted as a child because it still exists in the HTML.
CSS can mostly handle this now (with Firefox being the exception because it doesn’t yet support :has)… It’s probably worth adding a proper “hide 0 votes on topic list” option to the plugin to avoid the issue entirely… but for now this will work.
.vote-count-0 {
display: none; // hide 0 vote count
}
.discourse-tags:has(.vote-count-0) {
.discourse-tag:nth-last-child(2):after {
display: none; // hide the comma on the second to last tag
}
}