mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-05-15 04:19:08 +08:00
🐛 fix(data-grid): 修复拖拽调整列宽时意外触发列排序拖拽的问题
- ResizableTitle 的 resize handle 增加 onPointerDown stopPropagation - 阻止 pointerdown 事件冒泡到 @dnd-kit 的 PointerSensor - handleDragEnd 增加 isResizingRef 防御性检查,双重保险 - 确保列宽调整与列排序两个操作完全隔离
This commit is contained in:
@@ -362,6 +362,11 @@ const ResizableTitle = React.forwardRef<HTMLTableCellElement, any>((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<DataGridProps> = ({
|
||||
);
|
||||
|
||||
const handleDragEnd = (event: DragEndEvent) => {
|
||||
// 防御性检查:若正在调整列宽,忽略拖拽排序事件
|
||||
if (isResizingRef.current) return;
|
||||
const { active, over } = event;
|
||||
if (active.id !== over?.id && over) {
|
||||
setAllOrderedColumnNames((prevAllOrder) => {
|
||||
|
||||
Reference in New Issue
Block a user