From a9007bd0f3fc8c43498081612090ba86188892e1 Mon Sep 17 00:00:00 2001 From: zhouyun Date: Tue, 23 Jul 2024 16:52:40 +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)=20(#2946)?= 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]) /**