diff --git a/apps/web/modules/survey/editor/components/question-card.tsx b/apps/web/modules/survey/editor/components/question-card.tsx
index 95839eafec..82a7d66e11 100644
--- a/apps/web/modules/survey/editor/components/question-card.tsx
+++ b/apps/web/modules/survey/editor/components/question-card.tsx
@@ -195,7 +195,7 @@ export const QuestionCard = ({
{...attributes}
className={cn(
open ? "bg-slate-700" : "bg-slate-400",
- "top-0 w-10 rounded-l-lg p-2 text-center text-sm text-white hover:cursor-grab hover:bg-slate-600",
+ "top-0 w-10 rounded-l-lg p-2 text-center text-sm text-white hover:cursor-grab",
isInvalid && "bg-red-400 hover:bg-red-600",
"flex flex-col items-center justify-between"
)}>
diff --git a/apps/web/modules/survey/editor/components/questions-droppable.tsx b/apps/web/modules/survey/editor/components/questions-droppable.tsx
index bef20389e1..7ef664d2b0 100644
--- a/apps/web/modules/survey/editor/components/questions-droppable.tsx
+++ b/apps/web/modules/survey/editor/components/questions-droppable.tsx
@@ -1,5 +1,4 @@
import { SortableContext, verticalListSortingStrategy } from "@dnd-kit/sortable";
-import { useAutoAnimate } from "@formkit/auto-animate/react";
import { Project } from "@prisma/client";
import { TSurvey, TSurveyQuestionId } from "@formbricks/types/surveys/types";
import { TUserLocale } from "@formbricks/types/user";
@@ -48,10 +47,8 @@ export const QuestionsDroppable = ({
isStorageConfigured = true,
isExternalUrlsAllowed,
}: QuestionsDraggableProps) => {
- const [parent] = useAutoAnimate();
-
return (
-
+
{localSurvey.questions.map((question, questionIdx) => (
(null);
+
const sensors = useSensors(
useSensor(PointerSensor, {
activationConstraint: {
@@ -427,18 +432,31 @@ export const QuestionsView = ({
})
);
+ const onQuestionCardDragStart = (event: DragStartEvent) => {
+ setActiveQuestionDragId(event.active.id as string);
+ };
+
const onQuestionCardDragEnd = (event: DragEndEvent) => {
const { active, over } = event;
+ setActiveQuestionDragId(null);
+
+ if (!over || active.id === over.id) {
+ return;
+ }
const newQuestions = Array.from(localSurvey.questions);
const sourceIndex = newQuestions.findIndex((question) => question.id === active.id);
- const destinationIndex = newQuestions.findIndex((question) => question.id === over?.id);
+ const destinationIndex = newQuestions.findIndex((question) => question.id === over.id);
const [reorderedQuestion] = newQuestions.splice(sourceIndex, 1);
newQuestions.splice(destinationIndex, 0, reorderedQuestion);
const updatedSurvey = { ...localSurvey, questions: newQuestions };
setLocalSurvey(updatedSurvey);
};
+ const onQuestionCardDragCancel = () => {
+ setActiveQuestionDragId(null);
+ };
+
const onEndingCardDragEnd = (event: DragEndEvent) => {
const { active, over } = event;
const newEndings = Array.from(localSurvey.endings);
@@ -474,7 +492,9 @@ export const QuestionsView = ({
+
+ {activeQuestionDragId
+ ? (() => {
+ const draggedQuestion = localSurvey.questions.find((q) => q.id === activeQuestionDragId);
+ const draggedQuestionIdx = localSurvey.questions.findIndex(
+ (q) => q.id === activeQuestionDragId
+ );
+ return draggedQuestion ? (
+
+ setIsCautionDialogOpen(true)}
+ isStorageConfigured={isStorageConfigured}
+ isExternalUrlsAllowed={isExternalUrlsAllowed}
+ />
+
+ ) : null;
+ })()
+ : null}
+