Skip to content

Commit

Permalink
withTableSelection HOC background color fix (#1397)
Browse files Browse the repository at this point in the history
Co-authored-by: German Vorotnikov <[email protected]>
Co-authored-by: Mr.Dr.Professor Patrick <[email protected]>
  • Loading branch information
3 people authored Mar 5, 2024
1 parent f737c0c commit 256c153
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 256c153

Please sign in to comment.