Skip to content

Commit

Permalink
Add a comment, rename const
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewserong committed Sep 28, 2023
1 parent 61d1642 commit 4f388e9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/block-editor/src/components/list-view/branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function ListViewBranch( props ) {
// The appender means an extra row in List View, so add 1 to the row count.
const rowCount = showAppender ? blockCount + 1 : blockCount;
let nextPosition = listPosition;
const singleBlockSelection = selectedClientIds?.length === 1;
const isSingleBlockSelection = selectedClientIds?.length === 1;

return (
<>
Expand Down Expand Up @@ -169,11 +169,18 @@ function ListViewBranch( props ) {
);
const isSelectedBranch =
isBranchSelected || ( isSelected && hasNestedBlocks );

// To avoid performance issues, we only render blocks that are
// in view, or blocks that are selected or dragged.
// If a block is selected, it is only counted if it is the only
// block selected. This prevents the entire tree from being
// rendered when a branch is selected, or a user selects all blocks,
// while still enabling scroll into view behavior when selecting a block.
const showBlock =
isDragged ||
blockInView ||
isBranchDragged ||
( isSelected && singleBlockSelection );
( isSelected && isSingleBlockSelection );
return (
<AsyncModeProvider key={ clientId } value={ ! isSelected }>
{ showBlock && (
Expand Down

0 comments on commit 4f388e9

Please sign in to comment.