Skip to content

Commit

Permalink
Merge pull request #632 from whakama/master
Browse files Browse the repository at this point in the history
fix voting on polls clicking opening tweets + NaN css width vote count percentage bug
  • Loading branch information
dimdenGD authored Dec 7, 2023
2 parents 3ef50ce + 6cb332f commit fb4541a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion scripts/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ function generatePoll(tweet, tweetElement, user) {
if(user.id_str !== tweet.user.id_str && poll.selected_choice && choice.id === +poll.selected_choice.string_value) {
choice.selected = true;
}
choice.percentage = Math.round(choice.count / voteCount * 100);
choice.percentage = Math.round(choice.count / voteCount * 100) || 0;
let choiceElement = document.createElement('div');
choiceElement.classList.add('choice');
choiceElement.innerHTML = `
Expand All @@ -548,6 +548,7 @@ function generatePoll(tweet, tweetElement, user) {
let choice = choices[i];
let choiceElement = document.createElement('div');
choiceElement.classList.add('choice', 'choice-unselected');
choiceElement.classList.add('tweet-button');
choiceElement.innerHTML = `
<div class="choice-bg" style="width:100%"></div>
<div class="choice-label">${escapeHTML(choice.label)}</div>
Expand Down

0 comments on commit fb4541a

Please sign in to comment.