mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-01-23 09:06:23 +01:00
Fix poll showing NaN when total votes = 0
So 0/0 = NaN
This commit is contained in:
parent
318c2aeffc
commit
3daa7e4f9d
1 changed files with 5 additions and 4 deletions
|
@ -982,10 +982,11 @@ function Poll({ poll, readOnly, onUpdate = () => {} }) {
|
||||||
{voted || expired ? (
|
{voted || expired ? (
|
||||||
options.map((option, i) => {
|
options.map((option, i) => {
|
||||||
const { title, votesCount: optionVotesCount } = option;
|
const { title, votesCount: optionVotesCount } = option;
|
||||||
const percentage =
|
const percentage = pollVotesCount
|
||||||
((optionVotesCount / pollVotesCount) * 100).toFixed(
|
? ((optionVotesCount / pollVotesCount) * 100).toFixed(
|
||||||
roundPrecision,
|
roundPrecision,
|
||||||
) || 0;
|
)
|
||||||
|
: 0;
|
||||||
// check if current poll choice is the leading one
|
// check if current poll choice is the leading one
|
||||||
const isLeading =
|
const isLeading =
|
||||||
optionVotesCount > 0 &&
|
optionVotesCount > 0 &&
|
||||||
|
|
Loading…
Reference in a new issue