From 3d892db4367970fe52978cb8c97efe8d0418464f Mon Sep 17 00:00:00 2001 From: zhouyun1 Date: Mon, 1 Jul 2024 21:02:15 +0800 Subject: [PATCH] =?UTF-8?q?fix(table):=20=E4=BF=AE=E5=A4=8D=E5=88=97?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=97=AE=E9=A2=98=20(#2923)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/ui/table/src/hooks/use-col-width.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/ui/table/src/hooks/use-col-width.ts b/packages/ui/table/src/hooks/use-col-width.ts index 9420ce97b..2b7562bda 100644 --- a/packages/ui/table/src/hooks/use-col-width.ts +++ b/packages/ui/table/src/hooks/use-col-width.ts @@ -98,13 +98,16 @@ export const useColWidth = ({ }, [getVirtualWidths, virtual]) useUpdateEffect(() => { - setColWidths((prev) => { - return measureRowElementRef.current?.childNodes.length === prev.length - ? // 走更新逻辑 - getWidths(measureRowElementRef.current) - : // 当列数变化时重新走初始化逻辑 - getGroupItemWidth(columns) - }) + setColWidths(getGroupItemWidth(columns)) + // setColWidths((prev) => { + // // resizable 模式下通过 measureRowElementRef.current 去更新列宽,防止拖拽后宽度被重置 + // // 例如同时设置了 resizable 和 rowSelection,当拖拽某列宽度后再选中某行时,该列宽度会被重置 + // return resizable && measureRowElementRef.current?.childNodes.length === prev.length + // ? // 走更新逻辑 + // getWidths(measureRowElementRef.current) + // : // 当列数变化时重新走初始化逻辑 + // getGroupItemWidth(columns) + // }) }, [columns]) /**