Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
Fix navigator drag flickering (#1489)
Roman Pominov8495faa237d9
diff --git a/packages/design-system/src/components/primitives/dnd/use-drag.ts b/packages/design-system/src/components/primitives/dnd/use-drag.tsindex c4fdf60bd3..e75e97fb5c 100644--- a/packages/design-system/src/components/primitives/dnd/use-drag.ts+++ b/packages/design-system/src/components/primitives/dnd/use-drag.ts@@ -22,6 +22,10 @@ const initialState: State<unknown> = {type UseDragProps<DragItemData> = {startDistanceThreashold?: number;shiftDistanceThreshold?: number;+ /**+ * Checks whether the given element can be dragged.+ * If `false` is returned, drag will not start.+ */elementToData: (element: Element) => DragItemData | false;onStart: (event: { data: DragItemData }) => void;onMove: (event: Point) => void;diff --git a/packages/design-system/src/components/primitives/dnd/use-drop.ts b/packages/design-system/src/components/primitives/dnd/use-drop.tsindex f49ace956e..3639a736fd 100644--- a/packages/design-system/src/components/primitives/dnd/use-drop.ts+++ b/packages/design-system/src/components/primitives/dnd/use-drop.ts@@ -32,7 +32,13 @@ export type DropTarget<Data> = PartialDropTarget<Data> & {// For example, data found in elementToData// doesn't have to be looked up again in swapDropTarget.type UseDropProps<Data> = {- // To check that the element can qualify as a target+ /**+ * To check that the element can qualify as a drop target.+ * If `false` is returned, the parent of the element+ * will be suggested instead, and so on.+ * It's important to choose a correct element,+ * because it will be used for edge detection.+ */elementToData: (target: Element) => Data | false;// Distance from an edge to determine "area" value for swapDropTargetdiff --git a/packages/design-system/src/components/tree/tree.tsx b/packages/design-system/src/components/tree/tree.tsxindex 49485656ea..d49168b32d 100644--- a/packages/design-system/src/components/tree/tree.tsx+++ b/packages/design-system/src/components/tree/tree.tsx@@ -146,6 +146,13 @@ export const Tree = <Data extends { id: string }>({emulatePointerAlwaysInRootBounds: true,elementToData: (element) => {+ // We want to make sure edge detection is calculated relative+ // to the element with the data-drop-target-id attribute.+ // So, unless it has the attribute,+ // we return `false` to make useDrop go up the tree.+ if (element.getAttribute("data-drop-target-id") === null) {+ return false;+ }return getItemSelectorFromElement(element);},