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

Perf/table #2226

Merged
merged 3 commits into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions packages/ui/table/src/TableEmbedRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const TableEmbedRow = ({
getEmbedPanelById,
isEmbedLoadingId,
onEmbedSwitch,
scrollBodyElementRef,
} = useTableContext()

const loading = isEmbedLoadingId(rowData.id)
Expand Down
3 changes: 2 additions & 1 deletion packages/ui/table/src/styles/table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,11 @@ $prefix: '#{$component-prefix}-table' !default;
height: 100%;
bottom: 0;
right: 0;
border-left: 2px solid use-color('gray', 50);
cursor: col-resize;
z-index: 1;

&:hover {
.#{$prefix}-header__resizable:hover & {
background-color: use-color-mode('primary');
}
}
Expand Down
10 changes: 10 additions & 0 deletions packages/ui/table/src/use-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,16 @@ export const useTable = ({
nextColumns,
scrollWidth ? scrollWidth / lastColumns.length : 100
)

if (colWidths) {
// colWidths 记录的是最新的列宽,当它有值时,重置一下列宽,否则会导致冻结列动态调整宽度后定位不准
nextColumns = nextColumns.map((item, index) => {
return {
...item,
width: colWidths[index],
}
})
}
}

let leftColumns = [] as any[]
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/table/stories/async-expanded-render.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ export const AsyncExpandedRender = () => {
{
title: '商品名',
dataKey: 'name',
width: 120,
width: 150,
},
{
title: '品类',
dataKey: 'type',
width: 80,
width: 150,
},
{
title: '规格',
Expand Down