From d98df5ed3b80fe1c55821382e8cc005a397a4675 Mon Sep 17 00:00:00 2001 From: Dhruwang Jariwala <67850763+Dhruwang@users.noreply.github.com> Date: Wed, 8 May 2024 18:36:32 +0530 Subject: [PATCH] fix: close survey button on centerd app survey (#2587) --- packages/surveys/src/components/general/Survey.tsx | 6 +++++- packages/surveys/src/components/general/SurveyModal.tsx | 1 + packages/types/formbricksSurveys.ts | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/surveys/src/components/general/Survey.tsx b/packages/surveys/src/components/general/Survey.tsx index 6b654d6c9f..c672eff8b8 100644 --- a/packages/surveys/src/components/general/Survey.tsx +++ b/packages/surveys/src/components/general/Survey.tsx @@ -37,6 +37,7 @@ export const Survey = ({ onFileUpload, responseCount, startAtQuestionId, + clickOutside, }: SurveyBaseProps) => { const isInIframe = window.self !== window.top; const [questionId, setQuestionId] = useState( @@ -72,6 +73,9 @@ export const Survey = ({ }, [questionId, survey, history]); const contentRef = useRef(null); const showProgressBar = !styling.hideProgressBar; + const getShowSurveyCloseButton = (offset: number) => { + return offset === 0 && survey.type !== "link" && (clickOutside === undefined ? true : clickOutside); + }; useEffect(() => { // scroll to top when question changes @@ -326,7 +330,7 @@ export const Survey = ({ }; return ( - {offset === 0 && survey.type !== "link" && } + {getShowSurveyCloseButton(offset) && }
diff --git a/packages/types/formbricksSurveys.ts b/packages/types/formbricksSurveys.ts index ce450c783d..416838c8cb 100644 --- a/packages/types/formbricksSurveys.ts +++ b/packages/types/formbricksSurveys.ts @@ -23,6 +23,7 @@ export interface SurveyBaseProps { responseCount?: number; isCardBorderVisible?: boolean; startAtQuestionId?: string; + clickOutside?: boolean; } export interface SurveyInlineProps extends SurveyBaseProps {