From 6cae52d5e9c96153951576979d66986b55fa7334 Mon Sep 17 00:00:00 2001 From: zzman <43282255+GermanVor@users.noreply.github.com> Date: Tue, 5 Mar 2024 13:18:25 +0100 Subject: [PATCH] fix:(Table) withTableSelection HOC background color fix (#1401) Co-authored-by: German Vorotnikov --- .../withTableSelection/withTableSelection.tsx | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/components/Table/hoc/withTableSelection/withTableSelection.tsx b/src/components/Table/hoc/withTableSelection/withTableSelection.tsx index 6a068dc8a2..77a29c94b6 100644 --- a/src/components/Table/hoc/withTableSelection/withTableSelection.tsx +++ b/src/components/Table/hoc/withTableSelection/withTableSelection.tsx @@ -203,20 +203,26 @@ export function withTableSelection( // eslint-disable-next-line @typescript-eslint/member-ordering private enhanceGetRowDescriptor = _memoize( (getRowDescriptor?: TableProps['getRowDescriptor']) => { - return (item: I, index: number) => { + const currentGetRowDescriptor: TableProps['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; }, );