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
document -> document.documentElement
Roman Pominovb1d817e8d134
diff --git a/apps/designer/app/canvas/shared/use-drag-drop.ts b/apps/designer/app/canvas/shared/use-drag-drop.tsindex 47f486a59b..f24b305f49 100644--- a/apps/designer/app/canvas/shared/use-drag-drop.ts+++ b/apps/designer/app/canvas/shared/use-drag-drop.ts@@ -226,8 +226,8 @@ export const useDragAndDrop = () => {// We prefer useLayoutEffect over useEffect// because it's closer in the life cycle to when React noramlly calls the "ref" callbacks.useLayoutEffect(() => {- dropHandlers.rootRef(document);- dragHandlers.rootRef(document);+ dropHandlers.rootRef(document.documentElement);+ dragHandlers.rootRef(document.documentElement);window.addEventListener("scroll", dropHandlers.handleScroll);return () => {diff --git a/packages/design-system/src/components/primitives/dnd/use-drag.ts b/packages/design-system/src/components/primitives/dnd/use-drag.tsindex ef309fdbfc..ea80a638c1 100644--- a/packages/design-system/src/components/primitives/dnd/use-drag.ts+++ b/packages/design-system/src/components/primitives/dnd/use-drag.ts@@ -30,7 +30,7 @@ export type UseDragProps<DragItemData> = {};export type UseDragHandlers = {- rootRef: (element: HTMLElement | Document | null) => void;+ rootRef: (element: HTMLElement | null) => void;cancelCurrentDrag: () => void;};@@ -44,7 +44,7 @@ export const useDrag = <DragItemData>({elementToData,}: UseDragProps<DragItemData>): UseDragHandlers => {const state = useRef<State>(initialState);- const rootRef = useRef<HTMLElement | Document | null>(null);+ const rootRef = useRef<HTMLElement | null>(null);const dragItemData = useRef<DragItemData>();const detectShift = () => {@@ -137,16 +137,12 @@ export const useDrag = <DragItemData>({useEffect(() => {const roorElement = rootRef.current;if (roorElement !== null) {- // It should be fine to cast Document to HTMLElement here.- // The reason TypeScript complains otherwise is because for the Document's addEventListener()- // they don't define each type of event like "pointerdown",- // but only define a general case where the callback takes an `Event`.- (roorElement as HTMLElement).addEventListener(+ roorElement.addEventListener("pointerdown",useMoveHandlers.onPointerDown);return () => {- (roorElement as HTMLElement).removeEventListener(+ roorElement.removeEventListener("pointerdown",useMoveHandlers.onPointerDown);diff --git a/packages/design-system/src/components/primitives/dnd/use-drop.ts b/packages/design-system/src/components/primitives/dnd/use-drop.tsindex 7043810971..11405edc16 100644--- a/packages/design-system/src/components/primitives/dnd/use-drop.ts+++ b/packages/design-system/src/components/primitives/dnd/use-drop.ts@@ -78,7 +78,7 @@ export type UseDropHandlers = {handleScroll: () => void;handleStart: () => void;handleEnd: () => void;- rootRef: (target: Element | Document | null) => void;+ rootRef: (target: Element | null) => void;handleDomMutation: () => void;};@@ -100,7 +100,7 @@ export const useDrop = <Data>(props: UseDropProps<Data>): UseDropHandlers => {const latestProps = useRef<UseDropProps<Data>>(props);latestProps.current = props;- const rootRef = useRef<Element | Document | null>(null);+ const rootRef = useRef<Element | null>(null);const state = useRef(getInitialState<Data>());// We want to return a stable object to avoid re-renders when it's a dependency@@ -326,7 +326,7 @@ const findClosestDropTarget = <Data>({initialElement,elementToData,}: {- root: Element | Document;+ root: Element;initialElement: Element | undefined | null;elementToData: (target: Element) => Data | false;}): PartialDropTarget<Data> | undefined => {