Skip to content

Commit

Permalink
Merge pull request #2226 from XiaoMi/perf/table
Browse files Browse the repository at this point in the history
Perf/table
  • Loading branch information
solarjoker authored Sep 9, 2022
2 parents ffbc936 + 00f0eb8 commit 2985f53
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
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

0 comments on commit 2985f53

Please sign in to comment.