Skip to content

Commit

Permalink
fix(table): 修复列更新问题 (#2923)
Browse files Browse the repository at this point in the history
  • Loading branch information
zyprepare committed Jul 14, 2024
1 parent 8f888cb commit 3d892db
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions packages/ui/table/src/hooks/use-col-width.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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])

/**
Expand Down

0 comments on commit 3d892db

Please sign in to comment.