Skip to content

Commit 1a2961a

Browse files
Remove appender from unselected Buttons and Social Icons blocks. (#25518)
1 parent 06d1740 commit 1a2961a

File tree

1 file changed

+22
-19
lines changed
  • packages/block-editor/src/components/block-list-appender

1 file changed

+22
-19
lines changed

packages/block-editor/src/components/block-list-appender/index.js

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ function BlockListAppender( {
3838
if ( CustomAppender ) {
3939
// Prefer custom render prop if provided.
4040
appender = <CustomAppender />;
41-
} else if ( canInsertDefaultBlock ) {
42-
// Render the default block appender when renderAppender has not been
43-
// provided and the context supports use of the default appender.
41+
} else {
4442
const isDocumentAppender = ! rootClientId;
4543
const isParentSelected = selectedBlockClientId === rootClientId;
4644
const isAnotherDefaultAppenderAlreadyDisplayed =
@@ -50,26 +48,31 @@ function BlockListAppender( {
5048
if (
5149
! isDocumentAppender &&
5250
! isParentSelected &&
53-
isAnotherDefaultAppenderAlreadyDisplayed
51+
( ! selectedBlockClientId ||
52+
isAnotherDefaultAppenderAlreadyDisplayed )
5453
) {
5554
return null;
5655
}
5756

58-
appender = (
59-
<DefaultBlockAppender
60-
rootClientId={ rootClientId }
61-
lastBlockClientId={ last( blockClientIds ) }
62-
/>
63-
);
64-
} else {
65-
// Fallback in the case no renderAppender has been provided and the
66-
// default block can't be inserted.
67-
appender = (
68-
<ButtonBlockAppender
69-
rootClientId={ rootClientId }
70-
className="block-list-appender__toggle"
71-
/>
72-
);
57+
if ( canInsertDefaultBlock ) {
58+
// Render the default block appender when renderAppender has not been
59+
// provided and the context supports use of the default appender.
60+
appender = (
61+
<DefaultBlockAppender
62+
rootClientId={ rootClientId }
63+
lastBlockClientId={ last( blockClientIds ) }
64+
/>
65+
);
66+
} else {
67+
// Fallback in the case no renderAppender has been provided and the
68+
// default block can't be inserted.
69+
appender = (
70+
<ButtonBlockAppender
71+
rootClientId={ rootClientId }
72+
className="block-list-appender__toggle"
73+
/>
74+
);
75+
}
7376
}
7477

7578
return (

0 commit comments

Comments
 (0)