Skip to content

Commit fb27a70

Browse files
plagoafrancisco-guilherme
authored andcommitted
fix(SidePanel): prevent side panel content from being selected during resize
1 parent 3ab99f2 commit fb27a70

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

packages/pentaho/src/Canvas/SidePanel/useResizable.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { MouseEvent, useRef, useState } from "react";
1+
import { useRef, useState } from "react";
22
import { useForkRef } from "@hitachivantara/uikit-react-core";
33

44
interface ContainerProps {
@@ -64,23 +64,26 @@ export const useResizable = (
6464
};
6565

6666
const handleMouseUp = () => {
67+
if (!panelRef.current) return;
68+
69+
panelRef.current.style.userSelect = "";
6770
panelRef.current?.parentElement?.removeEventListener(
6871
"mousemove",
69-
mouseMove as unknown as EventListener,
72+
mouseMove,
7073
);
7174
panelRef.current?.parentElement?.removeEventListener(
7275
"mouseup",
73-
handleMouseUp as EventListener,
76+
handleMouseUp,
7477
);
7578
setIsDragging(false);
7679
};
7780

7881
const startResizing = () => {
79-
panelRef.current?.parentElement?.addEventListener(
80-
"mousemove",
81-
mouseMove as unknown as EventListener,
82-
);
83-
panelRef.current?.parentElement?.addEventListener("mouseup", handleMouseUp);
82+
if (!panelRef.current) return;
83+
84+
panelRef.current.style.userSelect = "none";
85+
panelRef.current.parentElement?.addEventListener("mousemove", mouseMove);
86+
panelRef.current.parentElement?.addEventListener("mouseup", handleMouseUp);
8487
setIsDragging(true);
8588
};
8689

0 commit comments

Comments
 (0)