From ab04db23c5a7e62dde94be78a20bc12147120eef Mon Sep 17 00:00:00 2001 From: HaixingOoO <974758671@qq.com> Date: Sun, 23 Jun 2024 18:38:51 +0800 Subject: [PATCH 1/2] fix(table): fix table resize drag prevent right click --- src/table/hooks/useColumnResize.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/table/hooks/useColumnResize.tsx b/src/table/hooks/useColumnResize.tsx index fb7d14ebd5..3edae3ef5c 100644 --- a/src/table/hooks/useColumnResize.tsx +++ b/src/table/hooks/useColumnResize.tsx @@ -208,7 +208,7 @@ export default function useColumnResize(params: { col: BaseTableCol, index: number, ) => { - if (!resizeLineParams.draggingCol) return; + if (e.button === 2 || !resizeLineParams.draggingCol) return; const target = resizeLineParams.draggingCol; const targetBoundRect = target.getBoundingClientRect(); const tableBoundRect = tableContentRef.current?.getBoundingClientRect(); From 6b9d875cc9c9dcd46dabb237b8d8b294497d586c Mon Sep 17 00:00:00 2001 From: HaixingOoO <974758671@qq.com> Date: Sun, 23 Jun 2024 21:03:19 +0800 Subject: [PATCH 2/2] chore(table): magic number set as variable --- src/table/hooks/useColumnResize.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/table/hooks/useColumnResize.tsx b/src/table/hooks/useColumnResize.tsx index 3edae3ef5c..2444e3d1ab 100644 --- a/src/table/hooks/useColumnResize.tsx +++ b/src/table/hooks/useColumnResize.tsx @@ -14,6 +14,8 @@ const DEFAULT_MIN_WIDTH = 80; const DEFAULT_MAX_WIDTH = 600; // 当离右边框的距离不超过 8 时,显示拖拽图标 const distance = 8; +// 鼠标右键 event.button = 2 +const CONTEXTMENU = 2; let originalSelectStart: (this: GlobalEventHandlers, ev: Event) => any; let originalDragStart: (this: GlobalEventHandlers, ev: Event) => any; @@ -208,7 +210,7 @@ export default function useColumnResize(params: { col: BaseTableCol, index: number, ) => { - if (e.button === 2 || !resizeLineParams.draggingCol) return; + if (e.button === CONTEXTMENU || !resizeLineParams.draggingCol) return; const target = resizeLineParams.draggingCol; const targetBoundRect = target.getBoundingClientRect(); const tableBoundRect = tableContentRef.current?.getBoundingClientRect();