mirror of
https://github.com/formbricks/formbricks.git
synced 2026-03-18 09:41:32 -05:00
Compare commits
2 Commits
cursor/for
...
cursor/saf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a0fb5c0b8 | ||
|
|
633bf18204 |
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
type CollisionDetection,
|
||||
DndContext,
|
||||
type DragEndEvent,
|
||||
KeyboardSensor,
|
||||
@@ -45,6 +46,42 @@ const SkeletonCell = () => (
|
||||
</Skeleton>
|
||||
);
|
||||
|
||||
/**
|
||||
* Safari-safe collision detection that validates getBoundingClientRect() properties
|
||||
* before using them. Safari can sometimes return DOMRect objects with undefined
|
||||
* properties (particularly 'top'), which causes dnd-kit to throw TypeErrors.
|
||||
*/
|
||||
const safariSafeClosestCenter: CollisionDetection = (args) => {
|
||||
const { droppableContainers } = args;
|
||||
|
||||
// Filter droppable containers to only include those with valid bounding rects
|
||||
const validDroppableContainers = droppableContainers.filter((container) => {
|
||||
const rect = container.rect.current;
|
||||
if (!rect) return false;
|
||||
|
||||
// Check if all required properties exist and are numbers
|
||||
return (
|
||||
typeof rect.top === "number" &&
|
||||
typeof rect.left === "number" &&
|
||||
typeof rect.right === "number" &&
|
||||
typeof rect.bottom === "number" &&
|
||||
typeof rect.width === "number" &&
|
||||
typeof rect.height === "number"
|
||||
);
|
||||
});
|
||||
|
||||
// If all containers were filtered out, return empty array (no collision)
|
||||
if (validDroppableContainers.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Call the original closestCenter with validated containers
|
||||
return closestCenter({
|
||||
...args,
|
||||
droppableContainers: validDroppableContainers,
|
||||
});
|
||||
};
|
||||
|
||||
interface ResponseTableProps {
|
||||
data: TResponseTableData[];
|
||||
survey: TSurvey;
|
||||
@@ -228,7 +265,7 @@ export const ResponseTable = ({
|
||||
<div>
|
||||
<DndContext
|
||||
id="response-table"
|
||||
collisionDetection={closestCenter}
|
||||
collisionDetection={safariSafeClosestCenter}
|
||||
modifiers={[restrictToHorizontalAxis]}
|
||||
onDragEnd={handleDragEnd}
|
||||
sensors={sensors}>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
type CollisionDetection,
|
||||
DndContext,
|
||||
type DragEndEvent,
|
||||
KeyboardSensor,
|
||||
@@ -33,6 +34,42 @@ import { deleteContactAttributeKeyAction } from "../actions";
|
||||
import { generateAttributeTableColumns } from "./attribute-table-column";
|
||||
import { EditAttributeModal } from "./edit-attribute-modal";
|
||||
|
||||
/**
|
||||
* Safari-safe collision detection that validates getBoundingClientRect() properties
|
||||
* before using them. Safari can sometimes return DOMRect objects with undefined
|
||||
* properties (particularly 'top'), which causes dnd-kit to throw TypeErrors.
|
||||
*/
|
||||
const safariSafeClosestCenter: CollisionDetection = (args) => {
|
||||
const { droppableContainers } = args;
|
||||
|
||||
// Filter droppable containers to only include those with valid bounding rects
|
||||
const validDroppableContainers = droppableContainers.filter((container) => {
|
||||
const rect = container.rect.current;
|
||||
if (!rect) return false;
|
||||
|
||||
// Check if all required properties exist and are numbers
|
||||
return (
|
||||
typeof rect.top === "number" &&
|
||||
typeof rect.left === "number" &&
|
||||
typeof rect.right === "number" &&
|
||||
typeof rect.bottom === "number" &&
|
||||
typeof rect.width === "number" &&
|
||||
typeof rect.height === "number"
|
||||
);
|
||||
});
|
||||
|
||||
// If all containers were filtered out, return empty array (no collision)
|
||||
if (validDroppableContainers.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Call the original closestCenter with validated containers
|
||||
return closestCenter({
|
||||
...args,
|
||||
droppableContainers: validDroppableContainers,
|
||||
});
|
||||
};
|
||||
|
||||
interface AttributesTableProps {
|
||||
contactAttributeKeys: TContactAttributeKey[];
|
||||
isReadOnly: boolean;
|
||||
@@ -230,7 +267,7 @@ export const AttributesTable = ({
|
||||
return (
|
||||
<div className="w-full">
|
||||
<DndContext
|
||||
collisionDetection={closestCenter}
|
||||
collisionDetection={safariSafeClosestCenter}
|
||||
modifiers={[restrictToHorizontalAxis]}
|
||||
onDragEnd={handleDragEnd}
|
||||
sensors={sensors}>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
type CollisionDetection,
|
||||
DndContext,
|
||||
type DragEndEvent,
|
||||
KeyboardSensor,
|
||||
@@ -32,6 +33,42 @@ import { Table, TableBody, TableCell, TableHeader, TableRow } from "@/modules/ui
|
||||
import { TContactTableData } from "../types/contact";
|
||||
import { generateContactTableColumns } from "./contact-table-column";
|
||||
|
||||
/**
|
||||
* Safari-safe collision detection that validates getBoundingClientRect() properties
|
||||
* before using them. Safari can sometimes return DOMRect objects with undefined
|
||||
* properties (particularly 'top'), which causes dnd-kit to throw TypeErrors.
|
||||
*/
|
||||
const safariSafeClosestCenter: CollisionDetection = (args) => {
|
||||
const { droppableContainers } = args;
|
||||
|
||||
// Filter droppable containers to only include those with valid bounding rects
|
||||
const validDroppableContainers = droppableContainers.filter((container) => {
|
||||
const rect = container.rect.current;
|
||||
if (!rect) return false;
|
||||
|
||||
// Check if all required properties exist and are numbers
|
||||
return (
|
||||
typeof rect.top === "number" &&
|
||||
typeof rect.left === "number" &&
|
||||
typeof rect.right === "number" &&
|
||||
typeof rect.bottom === "number" &&
|
||||
typeof rect.width === "number" &&
|
||||
typeof rect.height === "number"
|
||||
);
|
||||
});
|
||||
|
||||
// If all containers were filtered out, return empty array (no collision)
|
||||
if (validDroppableContainers.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Call the original closestCenter with validated containers
|
||||
return closestCenter({
|
||||
...args,
|
||||
droppableContainers: validDroppableContainers,
|
||||
});
|
||||
};
|
||||
|
||||
interface ContactsTableProps {
|
||||
data: TContactTableData[];
|
||||
fetchNextPage: () => void;
|
||||
@@ -224,7 +261,7 @@ export const ContactsTable = ({
|
||||
return (
|
||||
<div className="w-full">
|
||||
<DndContext
|
||||
collisionDetection={closestCenter}
|
||||
collisionDetection={safariSafeClosestCenter}
|
||||
modifiers={[restrictToHorizontalAxis]}
|
||||
onDragEnd={handleDragEnd}
|
||||
sensors={sensors}>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
type CollisionDetection,
|
||||
DndContext,
|
||||
DragEndEvent,
|
||||
PointerSensor,
|
||||
@@ -56,6 +57,42 @@ import { MultiLanguageCard } from "@/modules/survey/multi-language-surveys/compo
|
||||
import { ConfirmationModal } from "@/modules/ui/components/confirmation-modal";
|
||||
import { isEndingCardValid, isWelcomeCardValid, validateElement } from "../lib/validation";
|
||||
|
||||
/**
|
||||
* Safari-safe collision detection that validates getBoundingClientRect() properties
|
||||
* before using them. Safari can sometimes return DOMRect objects with undefined
|
||||
* properties (particularly 'top'), which causes dnd-kit to throw TypeErrors.
|
||||
*/
|
||||
const safariSafeClosestCorners: CollisionDetection = (args) => {
|
||||
const { droppableContainers } = args;
|
||||
|
||||
// Filter droppable containers to only include those with valid bounding rects
|
||||
const validDroppableContainers = droppableContainers.filter((container) => {
|
||||
const rect = container.rect.current;
|
||||
if (!rect) return false;
|
||||
|
||||
// Check if all required properties exist and are numbers
|
||||
return (
|
||||
typeof rect.top === "number" &&
|
||||
typeof rect.left === "number" &&
|
||||
typeof rect.right === "number" &&
|
||||
typeof rect.bottom === "number" &&
|
||||
typeof rect.width === "number" &&
|
||||
typeof rect.height === "number"
|
||||
);
|
||||
});
|
||||
|
||||
// If all containers were filtered out, return empty array (no collision)
|
||||
if (validDroppableContainers.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Call the original closestCorners with validated containers
|
||||
return closestCorners({
|
||||
...args,
|
||||
droppableContainers: validDroppableContainers,
|
||||
});
|
||||
};
|
||||
|
||||
interface ElementsViewProps {
|
||||
localSurvey: TSurvey;
|
||||
setLocalSurvey: React.Dispatch<SetStateAction<TSurvey>>;
|
||||
@@ -863,7 +900,7 @@ export const ElementsView = ({
|
||||
id="blocks"
|
||||
sensors={sensors}
|
||||
onDragEnd={onBlockCardDragEnd}
|
||||
collisionDetection={closestCorners}>
|
||||
collisionDetection={safariSafeClosestCorners}>
|
||||
<BlocksDroppable
|
||||
localSurvey={localSurvey}
|
||||
setLocalSurvey={setLocalSurvey}
|
||||
@@ -903,7 +940,7 @@ export const ElementsView = ({
|
||||
id="endings"
|
||||
sensors={sensors}
|
||||
onDragEnd={onEndingCardDragEnd}
|
||||
collisionDetection={closestCorners}>
|
||||
collisionDetection={safariSafeClosestCorners}>
|
||||
<SortableContext items={localSurvey.endings} strategy={verticalListSortingStrategy}>
|
||||
{localSurvey.endings.map((ending, index) => {
|
||||
return (
|
||||
|
||||
@@ -163,6 +163,9 @@ export const MultiLanguageCard: FC<MultiLanguageCardProps> = ({
|
||||
}
|
||||
} else {
|
||||
setIsMultiLanguageActivated(true);
|
||||
if (!open) {
|
||||
setOpen(true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
type CollisionDetection,
|
||||
DndContext,
|
||||
DragEndEvent,
|
||||
PointerSensor,
|
||||
@@ -24,6 +25,42 @@ import {
|
||||
} from "@/modules/ui/components/dialog";
|
||||
import { DataTableSettingsModalItem } from "./data-table-settings-modal-item";
|
||||
|
||||
/**
|
||||
* Safari-safe collision detection that validates getBoundingClientRect() properties
|
||||
* before using them. Safari can sometimes return DOMRect objects with undefined
|
||||
* properties (particularly 'top'), which causes dnd-kit to throw TypeErrors.
|
||||
*/
|
||||
const safariSafeClosestCorners: CollisionDetection = (args) => {
|
||||
const { droppableContainers } = args;
|
||||
|
||||
// Filter droppable containers to only include those with valid bounding rects
|
||||
const validDroppableContainers = droppableContainers.filter((container) => {
|
||||
const rect = container.rect.current;
|
||||
if (!rect) return false;
|
||||
|
||||
// Check if all required properties exist and are numbers
|
||||
return (
|
||||
typeof rect.top === "number" &&
|
||||
typeof rect.left === "number" &&
|
||||
typeof rect.right === "number" &&
|
||||
typeof rect.bottom === "number" &&
|
||||
typeof rect.width === "number" &&
|
||||
typeof rect.height === "number"
|
||||
);
|
||||
});
|
||||
|
||||
// If all containers were filtered out, return empty array (no collision)
|
||||
if (validDroppableContainers.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Call the original closestCorners with validated containers
|
||||
return closestCorners({
|
||||
...args,
|
||||
droppableContainers: validDroppableContainers,
|
||||
});
|
||||
};
|
||||
|
||||
interface DataTableSettingsModalProps<T> {
|
||||
open: boolean;
|
||||
setOpen: (open: boolean) => void;
|
||||
@@ -66,7 +103,7 @@ export const DataTableSettingsModal = <T,>({
|
||||
id="table-settings"
|
||||
sensors={sensors}
|
||||
onDragEnd={handleDragEnd}
|
||||
collisionDetection={closestCorners}>
|
||||
collisionDetection={safariSafeClosestCorners}>
|
||||
<SortableContext items={columnOrder} strategy={verticalListSortingStrategy}>
|
||||
{columnOrder.map((columnId) => {
|
||||
if (columnId === "select" || columnId === "createdAt") return;
|
||||
|
||||
@@ -269,7 +269,6 @@ test.describe("Multi Language Survey Create", async () => {
|
||||
await page.getByText("Start from scratch").click();
|
||||
await page.getByRole("button", { name: "Create survey", exact: true }).click();
|
||||
await page.locator("#multi-lang-toggle").click();
|
||||
await page.getByText("Multiple languages").click();
|
||||
await page.getByRole("combobox").click();
|
||||
await page.getByLabel("English (en)").click();
|
||||
await page.getByRole("button", { name: "Confirm" }).click();
|
||||
|
||||
Reference in New Issue
Block a user