File tree Expand file tree Collapse file tree 1 file changed +13
-9
lines changed
src/app/components/checkbox-tree/services Expand file tree Collapse file tree 1 file changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -262,21 +262,25 @@ export class DataStateService {
262262 totalCount : number ;
263263 } {
264264 let selectedCount = 0 ;
265- let totalCount = 1 ; // Count this node
265+ let totalCount = 0 ;
266266
267267 const isCheckedLeaf =
268268 node . isLeaf &&
269269 node . checkboxState . checked &&
270270 ! node . checkboxState . indeterminate ;
271- if ( isCheckedLeaf ) {
272- selectedCount += 1 ;
273- }
274271
275- // Count children
276- if ( node . children ) {
277- for ( const child of node . children ) {
278- selectedCount += child . selectedCount ?? 0 ;
279- totalCount += child . totalCount ?? 0 ;
272+ if ( node . isLeaf ) {
273+ totalCount = 1 ;
274+ if ( isCheckedLeaf ) {
275+ selectedCount += 1 ;
276+ }
277+ } else {
278+ // Count children
279+ if ( node . children ) {
280+ for ( const child of node . children ) {
281+ selectedCount += child . selectedCount ?? 0 ;
282+ totalCount += child . totalCount ?? 0 ;
283+ }
280284 }
281285 }
282286
You can’t perform that action at this time.
0 commit comments