Skip to content

Commit

Permalink
fix: change survey question on preview submit (#27274)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasheriques authored Jan 8, 2025
1 parent 6127b46 commit f18f65b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
14 changes: 7 additions & 7 deletions frontend/src/scenes/surveys/SurveyAppearancePreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import { Survey } from '~/types'
import { NewSurvey } from './constants'
import { surveysLogic } from './surveysLogic'

export function SurveyAppearancePreview({
survey,
previewPageIndex,
}: {
interface Props {
survey: Survey | NewSurvey
previewPageIndex: number
}): JSX.Element {
onPreviewSubmit?: (res: string | string[] | number | null) => void
}

export function SurveyAppearancePreview({ survey, previewPageIndex, onPreviewSubmit = () => {} }: Props): JSX.Element {
const surveyPreviewRef = useRef<HTMLDivElement>(null)
const feedbackWidgetPreviewRef = useRef<HTMLDivElement>(null)

Expand All @@ -26,6 +26,7 @@ export function SurveyAppearancePreview({
parentElement: surveyPreviewRef.current,
previewPageIndex,
forceDisableHtml: !surveysHTMLAvailable,
onPreviewSubmit,
})
}

Expand All @@ -36,11 +37,10 @@ export function SurveyAppearancePreview({
forceDisableHtml: !surveysHTMLAvailable,
})
}
}, [survey, previewPageIndex, surveysHTMLAvailable])
}, [survey, previewPageIndex, surveysHTMLAvailable, onPreviewSubmit])
return (
<>
<div ref={surveyPreviewRef} />
<div ref={feedbackWidgetPreviewRef} />
</>
)
}
6 changes: 5 additions & 1 deletion frontend/src/scenes/surveys/SurveyFormAppearance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ export function SurveyFormAppearance({
}: SurveyFormAppearanceProps): JSX.Element {
return survey.type !== SurveyType.API ? (
<div className="survey-view max-w-72">
<SurveyAppearancePreview survey={survey as Survey} previewPageIndex={previewPageIndex} />
<SurveyAppearancePreview
survey={survey as Survey}
previewPageIndex={previewPageIndex}
onPreviewSubmit={() => handleSetSelectedPageIndex(previewPageIndex + 1)}
/>
<LemonSelect
onChange={(pageIndex) => handleSetSelectedPageIndex(pageIndex)}
className="mt-4 whitespace-nowrap"
Expand Down

0 comments on commit f18f65b

Please sign in to comment.