From 3daa7e4f9d4716c07cf9202f9d55e80b1ef7afd1 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Sun, 25 Dec 2022 23:29:25 +0800 Subject: [PATCH] Fix poll showing NaN when total votes = 0 So 0/0 = NaN --- src/components/status.jsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/status.jsx b/src/components/status.jsx index 062cf87b..7088168e 100644 --- a/src/components/status.jsx +++ b/src/components/status.jsx @@ -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( - roundPrecision, - ) || 0; + const percentage = pollVotesCount + ? ((optionVotesCount / pollVotesCount) * 100).toFixed( + roundPrecision, + ) + : 0; // check if current poll choice is the leading one const isLeading = optionVotesCount > 0 &&