@@ -442,18 +442,26 @@ export const MoleculeList = memo(({ height, setFilterItemsHeight, filterItemsHei
442
442
handleFilterChange(newFilter);*/
443
443
} ;
444
444
445
- const changeButtonClassname = ( givenList = [ ] ) => {
446
- if ( joinedMoleculeLists . length === givenList . length ) {
445
+ const joinedGivenMatch = useCallback ( ( givenList ) => {
446
+ return givenList . filter ( element => joinedMoleculeLists . filter ( element2 => element2 . id === element ) . length > 0 ) . length ;
447
+ } , [ joinedMoleculeLists ] ) ;
448
+
449
+ const joinedLigandMatchLength = useMemo ( ( ) => joinedGivenMatch ( fragmentDisplayList ) , [ fragmentDisplayList , joinedGivenMatch ] ) ;
450
+ const joinedProteinMatchLength = useMemo ( ( ) => joinedGivenMatch ( proteinList ) , [ proteinList , joinedGivenMatch ] ) ;
451
+ const joinedComplexMatchLength = useMemo ( ( ) => joinedGivenMatch ( complexList ) , [ complexList , joinedGivenMatch ] ) ;
452
+
453
+ const changeButtonClassname = ( givenList = [ ] , matchListLength ) => {
454
+ if ( joinedMoleculeLists . length === matchListLength ) {
447
455
return true ;
448
- } else if ( givenList . length > 0 ) {
456
+ } else if ( givenList . length > 0 && matchListLength > 0 ) {
449
457
return null ;
450
458
}
451
459
return false ;
452
460
} ;
453
461
454
- const isLigandOn = changeButtonClassname ( fragmentDisplayList ) ;
455
- const isProteinOn = changeButtonClassname ( proteinList ) ;
456
- const isComplexOn = changeButtonClassname ( complexList ) ;
462
+ const isLigandOn = changeButtonClassname ( fragmentDisplayList , joinedLigandMatchLength ) ;
463
+ const isProteinOn = changeButtonClassname ( proteinList , joinedProteinMatchLength ) ;
464
+ const isComplexOn = changeButtonClassname ( complexList , joinedComplexMatchLength ) ;
457
465
458
466
const addType = {
459
467
ligand : addLigand ,
0 commit comments