summaryrefslogtreecommitdiff
path: root/apps/web/src/hooks
diff options
context:
space:
mode:
authorMaze Winther <mazewinther@gmail.com>2025-08-27 17:55:54 +0200
committerMaze Winther <mazewinther@gmail.com>2025-08-27 17:55:54 +0200
commitd4e08bb7e3ecfe944f683a26f063e6d7a487c992 (patch)
treee8580a6734c590a44c1c691b183e7ce9fa131a48 /apps/web/src/hooks
parent06e3d0ca2aba3d804a7abe58e6a72f07dbb69806 (diff)
downloadopencut-d4e08bb7e3ecfe944f683a26f063e6d7a487c992.tar.gz
fix: deselect text before timeline selection
Diffstat (limited to 'apps/web/src/hooks')
-rw-r--r--apps/web/src/hooks/use-selection-box.ts16
1 files changed, 16 insertions, 0 deletions
diff --git a/apps/web/src/hooks/use-selection-box.ts b/apps/web/src/hooks/use-selection-box.ts
index 46e77fa9..87026500 100644
--- a/apps/web/src/hooks/use-selection-box.ts
+++ b/apps/web/src/hooks/use-selection-box.ts
@@ -190,6 +190,22 @@ export function useSelectionBox({
};
}, [selectionBox, selectElementsInBox]);
+ useEffect(() => {
+ if (!selectionBox?.isActive) return;
+
+ const previousBodyUserSelect = document.body.style.userSelect;
+ const container = containerRef.current;
+ const previousContainerUserSelect = container?.style.userSelect ?? "";
+
+ document.body.style.userSelect = "none";
+ if (container) container.style.userSelect = "none";
+
+ return () => {
+ document.body.style.userSelect = previousBodyUserSelect;
+ if (container) container.style.userSelect = previousContainerUserSelect;
+ };
+ }, [selectionBox?.isActive, containerRef]);
+
return {
selectionBox,
handleMouseDown,