Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(table): 修复列更新问题 (#2923) #2946

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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