mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-01-23 00:56: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 ? (
|
||||
options.map((option, i) => {
|
||||
const { title, votesCount: optionVotesCount } = option;
|
||||
const percentage =
|
||||
((optionVotesCount / pollVotesCount) * 100).toFixed(
|
||||
const percentage = pollVotesCount
|
||||
? ((optionVotesCount / pollVotesCount) * 100).toFixed(
|
||||
roundPrecision,
|
||||
) || 0;
|
||||
)
|
||||
: 0;
|
||||
// check if current poll choice is the leading one
|
||||
const isLeading =
|
||||
optionVotesCount > 0 &&
|
||||
|
|
Loading…
Reference in a new issue