Skip to content

Commit 15e5ab4

Browse files
authored
chore: skip effect on shouldCellUpdate (#687)
1 parent 2d0d403 commit 15e5ab4

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

src/Cell/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ function Cell<RecordType extends DefaultRecordType>(
107107
startRow,
108108
endRow,
109109
onHover,
110+
111+
// MISC
112+
shouldCellUpdate,
110113
}: InternalCellProps<RecordType>,
111114
ref: React.Ref<any>,
112115
): React.ReactElement {
@@ -236,7 +239,7 @@ function Cell<RecordType extends DefaultRecordType>(
236239
[`${cellPrefixCls}-ellipsis`]: ellipsis,
237240
[`${cellPrefixCls}-with-append`]: appendNode,
238241
[`${cellPrefixCls}-fix-sticky`]: (isFixLeft || isFixRight) && isSticky && supportSticky,
239-
[`${cellPrefixCls}-row-hover`]: hovering,
242+
[`${cellPrefixCls}-row-hover`]: !shouldCellUpdate && hovering, // Not patch style if using shouldCellUpdate
240243
},
241244
additionalProps.className,
242245
cellClassName,

tests/Table.spec.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -932,9 +932,24 @@ describe('Table.Basic', () => {
932932
});
933933
});
934934

935-
it('hover', () => {
936-
const wrapper = mount(createTable());
937-
wrapper.find('tbody td').first().simulate('mouseEnter');
938-
expect(wrapper.exists('.rc-table-cell-row-hover')).toBeTruthy();
935+
describe('hover', () => {
936+
it('basic', () => {
937+
const wrapper = mount(createTable());
938+
wrapper.find('tbody td').first().simulate('mouseEnter');
939+
expect(wrapper.exists('.rc-table-cell-row-hover')).toBeTruthy();
940+
});
941+
942+
it('skip when config should cell update', () => {
943+
const wrapper = mount(
944+
createTable({
945+
columns: [
946+
{ title: 'Name', dataIndex: 'name', key: 'name', shouldCellUpdate: () => false },
947+
],
948+
}),
949+
);
950+
951+
wrapper.find('tbody td').first().simulate('mouseEnter');
952+
expect(wrapper.exists('.rc-table-cell-row-hover')).toBeFalsy();
953+
});
939954
});
940955
});

0 commit comments

Comments
 (0)