From 37bb3561cfd00617d5f66888bd118e8eb13e574c Mon Sep 17 00:00:00 2001 From: chaishi Date: Wed, 13 Jul 2022 18:01:19 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(table):=20=E5=88=97=E5=AE=BD=E6=8B=96?= =?UTF-8?q?=E6=8B=BD=E8=B0=83=E6=95=B4=E5=88=B0=E8=BE=B9=E7=95=8C=E6=97=B6?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E9=87=8D=E6=96=B0=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/table/hooks/useColumnResize.tsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/table/hooks/useColumnResize.tsx b/src/table/hooks/useColumnResize.tsx index ef8c94882..d8481d15f 100644 --- a/src/table/hooks/useColumnResize.tsx +++ b/src/table/hooks/useColumnResize.tsx @@ -58,9 +58,9 @@ export default function useColumnResize(tableContentRef: MutableRefObject { if (resizeLineParams.isDragging) { // 结束拖拽,更新列宽 - const width = parseInt(resizeLineLeft, 10) - colLeft; - + let width = Math.ceil(parseInt(resizeLineLeft, 10) - colLeft) || 0; + // 为了避免精度问题,导致 width 宽度超出 [minColWidth, maxColWidth] 的范围,需要对比目标宽度和最小/最大宽度 + if (width <= minColWidth) { + width = minColWidth; + } else if (width >= maxColWidth) { + width = maxColWidth; + } // eslint-disable-next-line - col.width = `${Math.floor(width)}px`; + col.width = `${width}px`; // 恢复设置 resizeLineParams.isDragging = false; From 956cef4150d6ab9539fbf945a0176393fad8df94 Mon Sep 17 00:00:00 2001 From: chaishi Date: Wed, 13 Jul 2022 18:02:14 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix(table):=20=E5=A4=9A=E7=BA=A7=E8=A1=A8?= =?UTF-8?q?=E5=A4=B4=E5=9C=BA=E6=99=AF=E4=B8=8B=E7=9A=84=E5=88=97=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=EF=BC=8C=E6=97=A0=E6=B3=95=E5=85=A8=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/table/hooks/useColumnController.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/table/hooks/useColumnController.tsx b/src/table/hooks/useColumnController.tsx index 1c3407756..1ef46785e 100644 --- a/src/table/hooks/useColumnController.tsx +++ b/src/table/hooks/useColumnController.tsx @@ -85,7 +85,8 @@ export default function useColumnController(props: TdPrimaryTableProps) { const handleClickAllShowColumns = (checked: boolean, ctx: { e: ChangeEvent }) => { if (checked) { - const newData = columns?.map((t) => t.colKey) || []; + const checkboxOptions = getCheckboxOptions(columns); + const newData = checkboxOptions?.map((t) => t.value) || []; columnCheckboxKeys.current = newData; props.onColumnChange?.({ type: 'check', columns: newData, e: ctx.e }); } else {