Skip to content

Commit

Permalink
chore: Make ratings start at 0 (#834)
Browse files Browse the repository at this point in the history
  • Loading branch information
neilkakkar authored Oct 17, 2023
1 parent 4af8c2d commit e85f2b3
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 @@ -463,13 +463,14 @@ export const addCancelListeners = (

export const createRatingsPopup = (posthog: PostHog, survey: Survey, question: RatingSurveyQuestion) => {
const scale = question.scale
const starting = question.scale === 10 ? 0 : 1
const displayType = question.display
const isOptional = !!question.optional
const ratingOptionsElement = document.createElement('div')
if (displayType === 'number') {
ratingOptionsElement.className = 'rating-options-buttons'
ratingOptionsElement.style.gridTemplateColumns = `repeat(${scale}, minmax(0, 1fr))`
for (let i = 1; i <= scale; i++) {
ratingOptionsElement.style.gridTemplateColumns = `repeat(${scale - starting + 1}, minmax(0, 1fr))`
for (let i = starting; i <= scale; i++) {
const buttonElement = document.createElement('button')
buttonElement.className = `ratings-number rating_${i} auto-text-color`
buttonElement.type = 'submit'
Expand Down

0 comments on commit e85f2b3

Please sign in to comment.