Skip to content

Commit

Permalink
fix: adds default value for survey feedback button appearance (#28000)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasheriques authored Jan 29, 2025
1 parent 581b80c commit 2803d99
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
3 changes: 3 additions & 0 deletions frontend/src/scenes/surveys/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ export const defaultSurveyAppearance = {
displayThankYouMessage: true,
thankYouMessageHeader: 'Thank you for your feedback!',
position: 'right',
widgetType: 'tab' as const,
widgetLabel: 'Feedback',
widgetColor: 'black',
}

export const defaultSurveyFieldValues = {
Expand Down
19 changes: 14 additions & 5 deletions frontend/src/scenes/surveys/surveyLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1332,6 +1332,19 @@ function sanitizeQuestions(surveyPayload: Partial<Survey>): Partial<Survey> {
const sanitizedThankYouHeader = sanitizeHTML(surveyPayload.appearance?.thankYouMessageHeader || '')
const sanitizedThankYouDescription = sanitizeHTML(surveyPayload.appearance?.thankYouMessageDescription || '')

const appearance = {
...surveyPayload.appearance,
...(sanitizedThankYouHeader && { thankYouMessageHeader: sanitizedThankYouHeader }),
...(sanitizedThankYouDescription && { thankYouMessageDescription: sanitizedThankYouDescription }),
}

// Remove widget-specific fields if survey type is not Widget
if (surveyPayload.type !== 'widget') {
delete appearance.widgetType
delete appearance.widgetLabel
delete appearance.widgetColor
}

return {
...surveyPayload,
questions: surveyPayload.questions?.map((rawQuestion) => {
Expand All @@ -1341,10 +1354,6 @@ function sanitizeQuestions(surveyPayload: Partial<Survey>): Partial<Survey> {
question: sanitizeHTML(rawQuestion.question || ''),
}
}),
appearance: {
...surveyPayload.appearance,
...(sanitizedThankYouHeader && { thankYouMessageHeader: sanitizedThankYouHeader }),
...(sanitizedThankYouDescription && { thankYouMessageDescription: sanitizedThankYouDescription }),
},
appearance,
}
}

0 comments on commit 2803d99

Please sign in to comment.