Skip to content

Commit 81a51ac

Browse files
committed
fix(ui): fix table fixed
1 parent b752ec3 commit 81a51ac

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

packages/platform/src/app/components/table/Table.tsx

+10-4
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,18 @@ export interface AppTableProps<T> {
5555
width: number | string;
5656
};
5757
aExpand?: (data: T, index: number) => React.ReactNode;
58+
aExpandFixed?: {
59+
top?: number | string;
60+
right?: number | string;
61+
bottom?: number | string;
62+
left?: number | string;
63+
};
5864
aScroll?: { x?: number | string; y?: number | string };
5965
aKey?: (data: T, index: number) => any;
6066
}
6167

6268
export function AppTable<T = any>(props: AppTableProps<T>): JSX.Element | null {
63-
const { className, aName, aData, aColumns, aActions, aExpand, aScroll, aKey = (data) => data['id'] } = props;
69+
const { className, aName, aData, aColumns, aActions, aExpand, aExpandFixed, aScroll, aKey = (data) => data['id'] } = props;
6470

6571
const columns = aColumns.filter((column) => !column.hidden);
6672
const titleIndex = columns.findIndex((column) => column.title);
@@ -76,7 +82,7 @@ export function AppTable<T = any>(props: AppTableProps<T>): JSX.Element | null {
7682
<DTable
7783
className={getClassName('d-none d-md-block', className)}
7884
style={{
79-
minHeight: aScroll?.y,
85+
maxHeight: aScroll?.y,
8086
overflowX: isUndefined(aScroll?.x) ? 'hidden' : 'auto',
8187
overflowY: isUndefined(aScroll?.y) ? 'hidden' : 'auto',
8288
}}
@@ -85,14 +91,14 @@ export function AppTable<T = any>(props: AppTableProps<T>): JSX.Element | null {
8591
{aName && <caption>{aName}</caption>}
8692
<thead>
8793
<tr>
88-
{!isUndefined(aExpand) && <DTable.Th dWidth={60}></DTable.Th>}
94+
{!isUndefined(aExpand) && <DTable.Th dWidth={60} dFixed={Object.assign({ top: 0 }, aExpandFixed)}></DTable.Th>}
8995
{columns.map((column, index) => (
9096
<DTable.Th
9197
key={index}
9298
dWidth={column.width}
9399
dSort={column.thProps?.sort}
94100
dActions={column.thProps?.actions}
95-
dFixed={column.fixed}
101+
dFixed={Object.assign({ top: 0 }, column.fixed)}
96102
dAlign={column.align}
97103
>
98104
{column.th}

packages/ui/src/components/table/Cell.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import { DTableContext } from './Table';
99

1010
const ZINDEX_CONFIG = {
1111
top: 5,
12-
right: 1,
12+
right: 2,
1313
bottom: 5,
14-
left: 1,
14+
left: 2,
1515
};
1616

1717
export interface DCellProps extends React.TdHTMLAttributes<HTMLTableCellElement> {
@@ -61,7 +61,7 @@ export function DCell(props: DCellProps): JSX.Element | null {
6161
fixedStyle = {
6262
...dFixed,
6363
position: 'sticky',
64-
zIndex: Object.keys(dFixed).reduce((previous, current) => previous + ZINDEX_CONFIG[current], 0),
64+
zIndex: (dTag === 'th' ? 1 : 0) + Object.keys(dFixed).reduce((previous, current) => previous + ZINDEX_CONFIG[current], 0),
6565
};
6666

6767
if ('left' in dFixed) {

0 commit comments

Comments
 (0)