mirror of
https://github.com/formbricks/formbricks.git
synced 2025-12-30 18:30:32 -06:00
isPreviewMode fix
This commit is contained in:
@@ -692,6 +692,7 @@ export function Survey({
|
||||
isCurrent={offset === 0}
|
||||
responseData={responseData}
|
||||
variablesData={currentVariables}
|
||||
isPreviewMode={isPreviewMode}
|
||||
/>
|
||||
);
|
||||
} else if (questionIdx >= localSurvey.questions.length) {
|
||||
|
||||
@@ -24,6 +24,7 @@ interface WelcomeCardProps {
|
||||
isCurrent: boolean;
|
||||
responseData: TResponseData;
|
||||
variablesData: TResponseVariables;
|
||||
isPreviewMode?: boolean;
|
||||
}
|
||||
|
||||
function TimerIcon() {
|
||||
@@ -76,6 +77,7 @@ export function WelcomeCard({
|
||||
isCurrent,
|
||||
responseData,
|
||||
variablesData,
|
||||
isPreviewMode = false,
|
||||
}: WelcomeCardProps) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
@@ -117,16 +119,13 @@ export function WelcomeCard({
|
||||
|
||||
useEffect(() => {
|
||||
const handleEnter = (e: KeyboardEvent) => {
|
||||
// Check if the event target is inside the editor
|
||||
if ((e.target as HTMLElement)?.closest(".editor")) {
|
||||
return;
|
||||
}
|
||||
if (e.key === "Enter") {
|
||||
handleSubmit();
|
||||
}
|
||||
};
|
||||
|
||||
if (isCurrent && survey.type === "link") {
|
||||
// Only attach listener when current, link type, and NOT in preview mode
|
||||
if (isCurrent && survey.type === "link" && !isPreviewMode) {
|
||||
document.addEventListener("keydown", handleEnter);
|
||||
} else {
|
||||
document.removeEventListener("keydown", handleEnter);
|
||||
@@ -136,8 +135,8 @@ export function WelcomeCard({
|
||||
document.removeEventListener("keydown", handleEnter);
|
||||
};
|
||||
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps -- only want to run this effect when isCurrent changes
|
||||
}, [isCurrent]);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps -- only want to run this effect when isCurrent or isPreviewMode changes
|
||||
}, [isCurrent, isPreviewMode]);
|
||||
|
||||
return (
|
||||
<ScrollableContainer>
|
||||
|
||||
Reference in New Issue
Block a user