Skip to content

Commit

Permalink
chore: optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
uyarn committed Sep 21, 2024
1 parent 14446b3 commit c0b03a2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/table/hooks/useRowExpand.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ export default function useRowExpand(props: TdPrimaryTableProps) {
(params: RowClassNameParams<TableRowData>) => {
// 如果没有配置展开行,则不需要增加展开收起相关的类名
if (!showExpandedRow) return null;
const { row } = params;
const { rowKey } = row;
const { row, rowKey } = params;
const currentRowKey = get(row, rowKey || 'id');
return tableExpandClasses[tExpandedRowKeys?.includes(currentRowKey) ? 'rowExpanded' : 'rowFolded'];
},
Expand Down
1 change: 1 addition & 0 deletions src/table/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,7 @@ export type TableRowAttributes<T> =
export interface RowClassNameParams<T> {
row: T;
rowIndex: number;
rowKey: string;
type?: 'body' | 'foot';
}

Expand Down
2 changes: 1 addition & 1 deletion src/table/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function formatRowClassNames(
let customClasses: ClassName = [];
for (let i = 0, len = rowClassList.length; i < len; i++) {
const rName = rowClassList[i];
let tClass = isFunction(rName) ? rName({ ...params, row: { ...params.row, rowKey } }) : rName;
let tClass = isFunction(rName) ? rName({ ...params, rowKey }) : rName;
if (isObject(tClass) && !(tClass instanceof Array)) {
// 根据下标设置行类名
tClass[rowIndex] && (tClass = tClass[rowIndex]);
Expand Down

0 comments on commit c0b03a2

Please sign in to comment.