Skip to content

Commit

Permalink
Remove appender from unselected Buttons and Social Icons blocks. (#25518
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ZebulanStanphill authored Sep 22, 2020
1 parent 06d1740 commit 1a2961a
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions packages/block-editor/src/components/block-list-appender/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ function BlockListAppender( {
if ( CustomAppender ) {
// Prefer custom render prop if provided.
appender = <CustomAppender />;
} else if ( canInsertDefaultBlock ) {
// Render the default block appender when renderAppender has not been
// provided and the context supports use of the default appender.
} else {
const isDocumentAppender = ! rootClientId;
const isParentSelected = selectedBlockClientId === rootClientId;
const isAnotherDefaultAppenderAlreadyDisplayed =
Expand All @@ -50,26 +48,31 @@ function BlockListAppender( {
if (
! isDocumentAppender &&
! isParentSelected &&
isAnotherDefaultAppenderAlreadyDisplayed
( ! selectedBlockClientId ||
isAnotherDefaultAppenderAlreadyDisplayed )
) {
return null;
}

appender = (
<DefaultBlockAppender
rootClientId={ rootClientId }
lastBlockClientId={ last( blockClientIds ) }
/>
);
} else {
// Fallback in the case no renderAppender has been provided and the
// default block can't be inserted.
appender = (
<ButtonBlockAppender
rootClientId={ rootClientId }
className="block-list-appender__toggle"
/>
);
if ( canInsertDefaultBlock ) {
// Render the default block appender when renderAppender has not been
// provided and the context supports use of the default appender.
appender = (
<DefaultBlockAppender
rootClientId={ rootClientId }
lastBlockClientId={ last( blockClientIds ) }
/>
);
} else {
// Fallback in the case no renderAppender has been provided and the
// default block can't be inserted.
appender = (
<ButtonBlockAppender
rootClientId={ rootClientId }
className="block-list-appender__toggle"
/>
);
}
}

return (
Expand Down

0 comments on commit 1a2961a

Please sign in to comment.