File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -87,13 +87,16 @@ export default function useRowInfo<RecordType>(
8787 const rowProps = onRow ?.( record , recordIndex ) ;
8888 const onRowClick = rowProps ?. onClick ;
8989
90- const onClick : React . MouseEventHandler < HTMLElement > = ( event , ...args ) => {
91- if ( expandRowByClick && mergedExpandable ) {
92- onTriggerExpand ( record , event ) ;
93- }
90+ const onClick : React . MouseEventHandler < HTMLElement > =
91+ onRowClick || ( expandRowByClick && mergedExpandable )
92+ ? ( event , ...args ) => {
93+ if ( expandRowByClick && mergedExpandable ) {
94+ onTriggerExpand ( record , event ) ;
95+ }
9496
95- onRowClick ?.( event , ...args ) ;
96- } ;
97+ onRowClick ?.( event , ...args ) ;
98+ }
99+ : undefined ;
97100
98101 // ====================== RowClassName ======================
99102 let computeRowClassName : string ;
Original file line number Diff line number Diff line change @@ -503,6 +503,25 @@ describe('Table.Basic', () => {
503503 } ) ;
504504
505505 describe ( 'onRow' , ( ) => {
506+ it ( 'does not attach an inert click handler by default' , ( ) => {
507+ const rowProps = [ ] ;
508+ const Row = props => {
509+ rowProps . push ( props ) ;
510+ return < tr { ...props } /> ;
511+ } ;
512+
513+ render (
514+ createTable ( {
515+ components : { body : { row : Row } } ,
516+ } ) ,
517+ ) ;
518+
519+ expect ( rowProps ) . not . toHaveLength ( 0 ) ;
520+ rowProps . forEach ( props => {
521+ expect ( props . onClick ) . toBeUndefined ( ) ;
522+ } ) ;
523+ } ) ;
524+
506525 it ( 'renders onRow correctly' , ( ) => {
507526 const onRow = ( record , index ) => ( {
508527 id : `row-${ record . key } ` ,
You can’t perform that action at this time.
0 commit comments