Skip to content

Commit d978593

Browse files
Hale DengHale
andauthored
fix: throw error when clicking row with no set onClick in onRow (#698)
Co-authored-by: Hale <[email protected]>
1 parent dd480b2 commit d978593

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/Body/BodyRow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function BodyRow<RecordType extends { children?: readonly RecordType[] }>(
9999
onInternalTriggerExpand(record, event);
100100
}
101101

102-
additionalProps?.onClick(event, ...args);
102+
additionalProps?.onClick?.(event, ...args);
103103
};
104104

105105
// ======================== Base tr row ========================

tests/Table.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ describe('Table.Basic', () => {
446446
expect(wrapper.find('tbody tr').length).toBeTruthy();
447447
wrapper.find('tbody tr').forEach((tr, index) => {
448448
expect(tr.props().id).toEqual(`row-${data[index].key}`);
449+
expect(tr.simulate.bind(tr, 'click')).not.toThrowError();
449450
});
450451
});
451452

0 commit comments

Comments
 (0)