Skip to content

Commit b710d51

Browse files
committed
fix: make callback on confirmation message instead
1 parent 6eac010 commit b710d51

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

src/extensions/surveys.tsx

+8-10
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ interface SurveyPopupProps {
693693
isPopup?: boolean
694694
onPreviewSubmit?: (res: string | string[] | number | null) => void
695695
onPopupSurveyDismissed?: () => void
696-
onPopupSurveySent?: () => void
696+
onCloseConfirmationMessage?: () => void
697697
}
698698

699699
export function SurveyPopup({
@@ -706,7 +706,7 @@ export function SurveyPopup({
706706
isPopup,
707707
onPreviewSubmit = () => {},
708708
onPopupSurveyDismissed = () => {},
709-
onPopupSurveySent = () => {},
709+
onCloseConfirmationMessage = () => {},
710710
}: SurveyPopupProps) {
711711
const isPreviewMode = Number.isInteger(previewPageIndex)
712712
// NB: The client-side code passes the millisecondDelay in seconds, but setTimeout expects milliseconds, so we multiply by 1000
@@ -741,9 +741,6 @@ export function SurveyPopup({
741741
},
742742
isPopup: isPopup || false,
743743
onPreviewSubmit,
744-
onPopupSurveySent: () => {
745-
onPopupSurveySent()
746-
},
747744
}}
748745
>
749746
{!shouldShowConfirmation ? (
@@ -761,7 +758,10 @@ export function SurveyPopup({
761758
contentType={survey.appearance?.thankYouMessageDescriptionContentType}
762759
appearance={survey.appearance || defaultSurveyAppearance}
763760
styleOverrides={{ ...style, ...confirmationBoxLeftStyle }}
764-
onClose={() => setIsPopupVisible(false)}
761+
onClose={() => {
762+
setIsPopupVisible(false)
763+
onCloseConfirmationMessage()
764+
}}
765765
/>
766766
)}
767767
</SurveyContext.Provider>
@@ -783,8 +783,7 @@ export function Questions({
783783
survey.appearance?.backgroundColor || defaultSurveyAppearance.backgroundColor
784784
)
785785
const [questionsResponses, setQuestionsResponses] = useState({})
786-
const { previewPageIndex, onPopupSurveyDismissed, isPopup, onPreviewSubmit, onPopupSurveySent } =
787-
useContext(SurveyContext)
786+
const { previewPageIndex, onPopupSurveyDismissed, isPopup, onPreviewSubmit } = useContext(SurveyContext)
788787
const [currentQuestionIndex, setCurrentQuestionIndex] = useState(previewPageIndex || 0)
789788
const surveyQuestions = useMemo(() => getDisplayOrderQuestions(survey), [survey])
790789

@@ -819,7 +818,6 @@ export function Questions({
819818
const nextStep = getNextSurveyStep(survey, displayQuestionIndex, res)
820819
if (nextStep === SurveyQuestionBranchingType.End) {
821820
sendSurveyEvent({ ...questionsResponses, [responseKey]: res }, survey, posthog)
822-
onPopupSurveySent()
823821
} else {
824822
setCurrentQuestionIndex(nextStep)
825823
}
@@ -1036,7 +1034,7 @@ export function FeedbackWidget({
10361034
removeSurveyFromFocus={removeSurveyFromFocus}
10371035
isPopup={true}
10381036
onPopupSurveyDismissed={resetShowSurvey}
1039-
onPopupSurveySent={resetShowSurvey}
1037+
onCloseConfirmationMessage={resetShowSurvey}
10401038
/>
10411039
)}
10421040
</Preact.Fragment>

src/extensions/surveys/surveys-utils.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,6 @@ interface SurveyContextProps {
741741
onPopupSurveyDismissed: () => void
742742
isPopup: boolean
743743
onPreviewSubmit: (res: string | string[] | number | null) => void
744-
onPopupSurveySent: () => void
745744
}
746745

747746
export const SurveyContext = createContext<SurveyContextProps>({
@@ -750,7 +749,6 @@ export const SurveyContext = createContext<SurveyContextProps>({
750749
onPopupSurveyDismissed: () => {},
751750
isPopup: true,
752751
onPreviewSubmit: () => {},
753-
onPopupSurveySent: () => {},
754752
})
755753

756754
interface RenderProps {

0 commit comments

Comments
 (0)