@@ -517,7 +517,6 @@ const getChildrenSelection = (
517517 if ( row . childRows ) {
518518 // Recursively select/deselect child rows
519519 getChildrenSelection ( row . childRows , uniqueRowId , selectedRows , checked , hierarchyValidation ) ;
520- getParentSelectedState ( row . childRows , rowKeyGetter ( row , uniqueRowId ) , uniqueRowId , selectedRows , checked ) ;
521520 }
522521 if ( checked ) {
523522 selectedRows . add ( rowKeyGetter ( row , uniqueRowId ) ) ;
@@ -594,25 +593,16 @@ const handleCheckboxUpdate = (
594593 hierarchyValidation ?: boolean
595594) => {
596595 const selected = new Set ( selectedRows ) ;
597- if ( hierarchyValidation ) {
598- if ( checked ) {
599- selected . add ( rowKeyGetter ( row , uniqueRowId ) ) ;
600- }
601- if ( row . childRows && Array . isArray ( row . childRows ) ) {
602- getChildrenSelection ( row . childRows , uniqueRowId , selected , checked , hierarchyValidation ) ;
603- }
604- } else {
605- if ( checked ) {
606- selected . add ( rowKeyGetter ( row , uniqueRowId ) ) ;
607- } else {
608- selected . delete ( rowKeyGetter ( row , uniqueRowId ) ) ;
609- }
610- if ( row . childRows && Array . isArray ( row . childRows ) ) {
611- getChildrenSelection ( row . childRows , uniqueRowId , selected , checked ) ;
612- }
613- if ( row . parentKey ) {
614- getParentSelectedState ( rows , row . parentKey , uniqueRowId , selected , checked ) ;
615- }
596+ if ( checked ) {
597+ selected . add ( rowKeyGetter ( row , uniqueRowId ) ) ;
598+ } else if ( ! hierarchyValidation ) {
599+ selected . delete ( rowKeyGetter ( row , uniqueRowId ) ) ;
600+ }
601+ if ( row . childRows && Array . isArray ( row . childRows ) ) {
602+ getChildrenSelection ( row . childRows , uniqueRowId , selected , checked ) ;
603+ }
604+ if ( row . parentKey ) {
605+ getParentSelectedState ( rows , row . parentKey , uniqueRowId , selected , checked ) ;
616606 }
617607 onSelectRows ?.( selected ) ;
618608} ;
0 commit comments