From 7598bf372bd43b3e20ef8d8d75ace12e33fefada Mon Sep 17 00:00:00 2001 From: Syngnat Date: Wed, 18 Mar 2026 14:43:26 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(data-grid):=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E6=8B=96=E6=8B=BD=E8=B0=83=E6=95=B4=E5=88=97=E5=AE=BD?= =?UTF-8?q?=E6=97=B6=E6=84=8F=E5=A4=96=E8=A7=A6=E5=8F=91=E5=88=97=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E6=8B=96=E6=8B=BD=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ResizableTitle 的 resize handle 增加 onPointerDown stopPropagation - 阻止 pointerdown 事件冒泡到 @dnd-kit 的 PointerSensor - handleDragEnd 增加 isResizingRef 防御性检查,双重保险 - 确保列宽调整与列排序两个操作完全隔离 --- frontend/src/components/DataGrid.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/frontend/src/components/DataGrid.tsx b/frontend/src/components/DataGrid.tsx index 4791114..2ac62b6 100644 --- a/frontend/src/components/DataGrid.tsx +++ b/frontend/src/components/DataGrid.tsx @@ -362,6 +362,11 @@ const ResizableTitle = React.forwardRef((props, ref) // Pass the header element reference implicitly via event target onResizeStart(e); }} + onPointerDown={(e) => { + // 阻止 pointerdown 冒泡到 @dnd-kit 的 PointerSensor, + // 避免调整列宽时意外触发列拖拽排序 + e.stopPropagation(); + }} onClick={(e) => e.stopPropagation()} style={{ position: 'absolute', @@ -841,6 +846,8 @@ const DataGrid: React.FC = ({ ); const handleDragEnd = (event: DragEndEvent) => { + // 防御性检查:若正在调整列宽,忽略拖拽排序事件 + if (isResizingRef.current) return; const { active, over } = event; if (active.id !== over?.id && over) { setAllOrderedColumnNames((prevAllOrder) => {