Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block Editor: Optimize BlockListAppender #56116

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ function useAppender( rootClientId, CustomAppender ) {
getBlockEditingMode,
} = select( blockEditorStore );

if ( CustomAppender === false ) {
return false;
}

if ( ! CustomAppender ) {
const selectedBlockClientId = getSelectedBlockClientId();
const isParentSelected =
Expand Down Expand Up @@ -92,6 +88,26 @@ function BlockListAppender( {
renderAppender,
className,
tagName: TagName = 'div',
} ) {
if ( renderAppender === false ) {
return null;
}
Comment on lines +92 to +94
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What we're mostly doing is moving this condition a level above and moving the rest to a subcomponent. That way if the appender is false, we'll not have to create extra subscriptions because the subcomponent will never be rendered.


return (
<BlockListAppenderInner
rootClientId={ rootClientId }
renderAppender={ renderAppender }
className={ className }
tagName={ TagName }
/>
);
}

function BlockListAppenderInner( {
rootClientId,
renderAppender,
className,
tagName: TagName,
} ) {
const appender = useAppender( rootClientId, renderAppender );
const isDragOver = useSelect(
Expand Down