Skip to content

Commit

Permalink
perf(table): 修改内嵌内容固定展示
Browse files Browse the repository at this point in the history
  • Loading branch information
zyprepare committed Sep 7, 2022
1 parent d561f56 commit 4c482d5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
8 changes: 7 additions & 1 deletion 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 All @@ -38,7 +39,12 @@ export const TableEmbedRow = ({
<td colSpan={colSpan}>
{/* 乐观渲染:内嵌面板内容 */}
<Loading size="sm" visible={loading} part>
{getEmbedPanelById(rowData.id)}
<div
className={`${prefixCls}__wrapper`}
style={{ width: scrollBodyElementRef.current?.clientWidth }}
>
{getEmbedPanelById(rowData.id)}
</div>
</Loading>
</td>
</tr>
Expand Down
12 changes: 10 additions & 2 deletions packages/ui/table/src/styles/table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,17 @@ $prefix: '#{$component-prefix}-table' !default;
position: relative;
z-index: 0;

& > td {
background-color: use-color('gray', 200);
&__wrapper {
box-sizing: border-box;
position: sticky;
left: 0;
padding: use-spacing(10);
overflow: hidden;
background-color: use-color('gray', 200);
}

& > td {
padding: 0;
}
}

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 4c482d5

Please sign in to comment.