isPreviewMode fix

This commit is contained in:
pandeymangg
2025-10-27 21:16:51 +05:30
parent bf2f4ea381
commit b3fe7ee4d9
2 changed files with 7 additions and 7 deletions

View File

@@ -692,6 +692,7 @@ export function Survey({
isCurrent={offset === 0}
responseData={responseData}
variablesData={currentVariables}
isPreviewMode={isPreviewMode}
/>
);
} else if (questionIdx >= localSurvey.questions.length) {

View File

@@ -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>