Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions packages/block-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- `BlockListBlock`: Skip that deep check behind `isSelectionWithinCurrentSection` when the block is not within a section block, where it was passed an `undefined` client ID that never matches. Together the two changes take selecting all blocks on a 1000 paragraph post from 16.8s to 0.4s ([#81210](https://github.com/WordPress/gutenberg/pull/81210)).
- `ListView`: Drop the `useBlockDisplayInformation` and `useBlockLock` calls from the row, select button and branch components, reading the few fields they were used for from the `useSelect` each component already has. Store subscriptions go from seven to four per rendered row, and from two to one per branch ([#81136](https://github.com/WordPress/gutenberg/pull/81136)).
- `ListView`: Collapse the placeholder rows that stand in for blocks outside of the render window into a single spacer row per run, instead of rendering a `<tr>`/`<td>` pair for every block. On a post with 1000 top-level blocks this removes ~1900 elements (about 60% of the List View's DOM and nearly half of the document's elements), which cuts the style recalculation and layout work done when the List View opens ([#80953](https://github.com/WordPress/gutenberg/pull/80953)).
- `hasSelectedInnerBlock`: Return `false` up front when called without a client ID, instead of reading the selection and walking it for a check that can never match. The root client ID (`''`) is covered by the same bail out, so the shallow check no longer reports `true` when a top level block is selected, matching the deep check ([#81315](https://github.com/WordPress/gutenberg/pull/81315)).

### Internal

Expand Down
6 changes: 1 addition & 5 deletions packages/block-editor/src/components/block-list/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -686,13 +686,9 @@ function BlockListBlockProvider( props ) {
const sectionBlockClientId = isSectionBlock
? clientId
: getParentSectionBlock( clientId );
// Without a section block there is nothing for the deep check to
// match, and it walks the parents of every selected block to find
// that out.
const isSelectionWithinCurrentSection =
isBlockSelected( sectionBlockClientId ) ||
( !! sectionBlockClientId &&
hasSelectedInnerBlock( sectionBlockClientId, checkDeep ) );
hasSelectedInnerBlock( sectionBlockClientId, checkDeep );

const multiple = hasBlockSupport( blockName, 'multiple', true );

Expand Down
5 changes: 4 additions & 1 deletion packages/block-editor/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1357,8 +1357,11 @@ const getSelectedBlockAncestors = createSelector(
* @return {boolean} Whether the block has an inner block selected
*/
export function hasSelectedInnerBlock( state, clientId, deep = false ) {
const selectedBlockClientIds = getSelectedBlockClientIds( state );
if ( ! clientId ) {
return false;
}

const selectedBlockClientIds = getSelectedBlockClientIds( state );
if ( ! selectedBlockClientIds.length ) {
return false;
}
Expand Down
Loading