Skip to content

Commit 486a19a

Browse files
committed
fix: only show dependent children/parents when needed
1 parent 35b766b commit 486a19a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/welcome/admin.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -914,17 +914,17 @@ const Blocks = props => {
914914

915915
// Check if a parent is being enabled
916916
if ( valueInt === BLOCK_STATE.ENABLED ) {
917-
// Get the parent's children and confirm if they will also be enabled
918-
const childrenBlocks = getChildrenBlocks( name )
917+
// Get the parent's disabled/hidden children and confirm if they will also be enabled
918+
const childrenBlocks = getChildrenBlocks( name ).filter( block => block in disabledBlocks )
919919
if ( childrenBlocks.length > 0 ) {
920920
setCurrentToggleBlockList( childrenBlocks )
921921
setIsEnabledDialogOpen( true )
922922
} else {
923923
delete newDisabledBlocks[ name ]
924924
}
925925
} else if ( valueInt === BLOCK_STATE.DISABLED ) { // Check if a child is being disabled
926-
// Get the child's parents and confirm if they will also be disabled
927-
const parentBlocks = getParentBlocks( name )
926+
// Get the child's enabled parents and confirm if they will also be disabled
927+
const parentBlocks = getParentBlocks( name ).filter( block => ! ( block in disabledBlocks ) )
928928
if ( parentBlocks.length > 0 ) {
929929
setCurrentToggleBlockList( parentBlocks )
930930
setIsDisabledDialogOpen( true )
@@ -958,7 +958,7 @@ const Blocks = props => {
958958

959959
return (
960960
<>
961-
{ isDisabledDialogOpen && (
961+
{ isDisabledDialogOpen && currentToggleBlockList && (
962962
<ToggleBlockDialog
963963
blockName={ currentToggleBlock }
964964
blockList={ currentToggleBlockList }
@@ -970,7 +970,7 @@ const Blocks = props => {
970970
/>
971971
) }
972972

973-
{ isEnabledDialogOpen && (
973+
{ isEnabledDialogOpen && currentToggleBlockList && (
974974
<ToggleBlockDialog
975975
blockName={ currentToggleBlock }
976976
blockList={ currentToggleBlockList }

0 commit comments

Comments
 (0)