From 8114ecd3b1a9bc5dc6f0251289014059d5665f2a Mon Sep 17 00:00:00 2001 From: tanshuang <18983716373> Date: Thu, 24 Aug 2023 11:25:45 +0800 Subject: [PATCH] fix: when some web browser such as webkit, drag will Dragging will result in selected text --- src/index.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/index.tsx b/src/index.tsx index fa8ce51..1ff3e6a 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -2,6 +2,7 @@ import React, { useEffect, useReducer, useRef, + useState } from 'react'; import type { MouseEvent, TouchEvent } from 'react'; @@ -85,7 +86,7 @@ function Split({ const children = flattenChildren(reactChildren) const [state, dispatch] = useReducer(reducer, initialState); - + const [style, setStyle] = useState({}) const containerRef = useRef(null) const childRefs = useRef([]); const gutterRefs = useRef([]); @@ -108,6 +109,7 @@ function Split({ }); const pair = state.pairs[gutterIdx]; + setStyle({userSelect: 'none'}) onResizeStarted?.(pair.idx) // Disable selection. @@ -152,6 +154,7 @@ function Split({ if (state.draggingIdx === undefined) throw new Error(`Could not reset cursor and user-select because 'state.draggingIdx' is undefined`); const pair = state.pairs[state.draggingIdx]; + setStyle({}) onResizeFinished?.(pair.idx, allSizes); // Disable selection. @@ -395,6 +398,7 @@ function Split({
{state.isReady && children.map((c, idx) => (