Skip to content

Commit

Permalink
fix:(Table) withTableSelection HOC background color fix (#1401)
Browse files Browse the repository at this point in the history
Co-authored-by: German Vorotnikov <[email protected]>
  • Loading branch information
GermanVor and German Vorotnikov authored Mar 5, 2024
1 parent f9b4f61 commit 6cae52d
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/components/Table/hoc/withTableSelection/withTableSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,20 +203,26 @@ export function withTableSelection<I extends TableDataItem, E extends {} = {}>(
// eslint-disable-next-line @typescript-eslint/member-ordering
private enhanceGetRowDescriptor = _memoize(
(getRowDescriptor?: TableProps<I>['getRowDescriptor']) => {
return (item: I, index: number) => {
const currentGetRowDescriptor: TableProps<I>['getRowDescriptor'] = (
item: I,
index: number,
) => {
const {selectedIds, getRowClassNames} = this.props;
const classNames =
getRowDescriptor?.(item, index)?.classNames?.slice() ||
getRowClassNames?.(item, index) ||
[];
const descriptor = getRowDescriptor?.(item, index) || {};

if (descriptor.classNames === undefined) {
descriptor.classNames = getRowClassNames?.(item, index) || [];
}

const id = Table.getRowId(this.props, item, index);
const selected = selectedIds.includes(id);

classNames.push(b('row', {selected}));
descriptor.classNames.push(b('row', {selected}));

return classNames;
return descriptor;
};

return currentGetRowDescriptor;
},
);

Expand Down

0 comments on commit 6cae52d

Please sign in to comment.