Skip to content

Commit d4e08bb

Browse files
committed
fix: deselect text before timeline selection
1 parent 06e3d0c commit d4e08bb

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

apps/web/src/hooks/use-selection-box.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,22 @@ export function useSelectionBox({
190190
};
191191
}, [selectionBox, selectElementsInBox]);
192192

193+
useEffect(() => {
194+
if (!selectionBox?.isActive) return;
195+
196+
const previousBodyUserSelect = document.body.style.userSelect;
197+
const container = containerRef.current;
198+
const previousContainerUserSelect = container?.style.userSelect ?? "";
199+
200+
document.body.style.userSelect = "none";
201+
if (container) container.style.userSelect = "none";
202+
203+
return () => {
204+
document.body.style.userSelect = previousBodyUserSelect;
205+
if (container) container.style.userSelect = previousContainerUserSelect;
206+
};
207+
}, [selectionBox?.isActive, containerRef]);
208+
193209
return {
194210
selectionBox,
195211
handleMouseDown,

0 commit comments

Comments
 (0)