@@ -103,11 +103,11 @@ export function TaxonomyTree(props: ITaxonomyTreeProps): React.ReactElement<ITax
103
103
}
104
104
groupToAddTermTo . children = [ ...groupToAddTermTo . children ?? [ ] , g ] ;
105
105
props . setTerms ( ( prevTerms ) => {
106
- const nonExistingTerms = newTermItems . filter ( ( term ) => prevTerms . every ( ( prevTerm ) => prevTerm . id !== term . id ) ) ;
106
+ const nonExistingTerms = newTermItems . filter ( ( newTerm ) => prevTerms . every ( ( prevTerm ) => prevTerm . id !== newTerm . id ) ) ;
107
107
return [ ...prevTerms , ...nonExistingTerms ] ;
108
108
} ) ;
109
109
}
110
- }
110
+ } ;
111
111
112
112
const updateTaxonomyTreeViewWithUpdatedTermItems = ( updatedTermItems : ITermInfo [ ] ) : void => {
113
113
for ( const term of updatedTermItems ) {
@@ -143,7 +143,7 @@ export function TaxonomyTree(props: ITaxonomyTreeProps): React.ReactElement<ITax
143
143
return [ ...prevTerms . filter ( t => t . id !== term . id ) , term ] ;
144
144
} ) ;
145
145
}
146
- }
146
+ } ;
147
147
148
148
const updateTaxonomyTreeViewWithDeletedTermItems = ( deletedTermItems : ITermInfo [ ] ) : void => {
149
149
for ( const term of deletedTermItems ) {
@@ -168,7 +168,7 @@ export function TaxonomyTree(props: ITaxonomyTreeProps): React.ReactElement<ITax
168
168
return [ ...prevTerms . filter ( t => t . id !== term . id ) ] ;
169
169
} ) ;
170
170
}
171
- }
171
+ } ;
172
172
173
173
const updateTaxonomyTreeView = ( newTermItems ?: ITermInfo [ ] , updatedTermItems ?: ITermInfo [ ] , deletedTermItems ?: ITermInfo [ ] ) : void => {
174
174
if ( newTermItems ) {
@@ -182,7 +182,7 @@ export function TaxonomyTree(props: ITaxonomyTreeProps): React.ReactElement<ITax
182
182
if ( deletedTermItems ) {
183
183
updateTaxonomyTreeViewWithDeletedTermItems ( deletedTermItems ) ;
184
184
}
185
- }
185
+ } ;
186
186
187
187
React . useEffect ( ( ) => {
188
188
let termRootName = "" ;
@@ -405,7 +405,9 @@ export function TaxonomyTree(props: ITaxonomyTreeProps): React.ReactElement<ITax
405
405
{ p . label }
406
406
</ span > }
407
407
onChange = { ( ev ?: React . FormEvent < HTMLElement | HTMLInputElement > , checked ?: boolean ) => {
408
- props . selection && props . selection . setKeySelected ( groupHeaderProps . group . key , checked , false ) ;
408
+ if ( props . selection ) {
409
+ props . selection . setKeySelected ( groupHeaderProps . group . key , checked , false ) ;
410
+ }
409
411
} }
410
412
/>
411
413
< div className = { styles . actionButtonContainer } >
@@ -425,8 +427,10 @@ export function TaxonomyTree(props: ITaxonomyTreeProps): React.ReactElement<ITax
425
427
{ p . text }
426
428
</ span > ,
427
429
onClick : ( ) => {
428
- props . selection && props . selection . setAllSelected ( false ) ;
429
- props . selection && props . selection . setKeySelected ( groupHeaderProps . group . key , true , false ) ;
430
+ if ( props . selection ) {
431
+ props . selection . setAllSelected ( false ) ;
432
+ props . selection . setKeySelected ( groupHeaderProps . group . key , true , false ) ;
433
+ }
430
434
}
431
435
} ] ;
432
436
@@ -475,11 +479,15 @@ export function TaxonomyTree(props: ITaxonomyTreeProps): React.ReactElement<ITax
475
479
onGroupHeaderKeyUp = { ( ev : React . KeyboardEvent < HTMLElement > , group : IGroup ) => {
476
480
if ( ( ev . key == " " || ev . key == "Enter" ) && ! isDisabled ) {
477
481
if ( props . allowMultipleSelections ) {
478
- props . selection && props . selection . toggleKeySelected ( headerProps . group . key ) ;
482
+ if ( props . selection ) {
483
+ props . selection . toggleKeySelected ( headerProps . group . key ) ;
484
+ }
479
485
}
480
486
else {
481
- props . selection && props . selection . setAllSelected ( false ) ;
482
- props . selection && props . selection . setKeySelected ( headerProps . group . key , true , false ) ;
487
+ if ( props . selection ) {
488
+ props . selection . setAllSelected ( false ) ;
489
+ props . selection . setKeySelected ( headerProps . group . key , true , false ) ;
490
+ }
483
491
}
484
492
}
485
493
} }
0 commit comments