Skip to content

Commit

Permalink
fix(table): 修复冻结列动态调整宽度问题
Browse files Browse the repository at this point in the history
  • Loading branch information
zyprepare committed Sep 7, 2022
1 parent 4c482d5 commit e3c0d06
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
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

0 comments on commit e3c0d06

Please sign in to comment.