Skip to content

Commit

Permalink
fix(surveys): add listener to 0th element
Browse files Browse the repository at this point in the history
  • Loading branch information
neilkakkar committed Oct 17, 2023
1 parent ae7b04a commit d9179a9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/extensions/surveys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -549,8 +549,9 @@ export const createRatingsPopup = (posthog: PostHog, survey: Survey, question: R
})
}
formElement.getElementsByClassName('rating-options')[0].insertAdjacentElement('afterbegin', ratingOptionsElement)
for (const x of Array(question.scale).keys()) {
const ratingEl = formElement.getElementsByClassName(`rating_${x + 1}`)[0]
const allElements = question.scale === 10 ? [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] : [1, 2, 3, 4, 5]
for (const x of allElements) {
const ratingEl = formElement.getElementsByClassName(`rating_${x}`)[0]
ratingEl.addEventListener('click', (e) => {
e.preventDefault()
for (const activeRatingEl of formElement.getElementsByClassName('rating-active')) {
Expand Down

0 comments on commit d9179a9

Please sign in to comment.