Skip to content

Commit

Permalink
Columns: Replace some store selectors with 'getBlockOrder' (#67991)
Browse files Browse the repository at this point in the history
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: t-hamano <[email protected]>
  • Loading branch information
3 people authored Dec 14, 2024
1 parent aed83a9 commit 6e85888
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions packages/block-library/src/columns/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,15 @@ function ColumnInspectorControls( {
} ) {
const { count, canInsertColumnBlock, minCount } = useSelect(
( select ) => {
const {
canInsertBlockType,
canRemoveBlock,
getBlocks,
getBlockCount,
} = select( blockEditorStore );
const innerBlocks = getBlocks( clientId );
const { canInsertBlockType, canRemoveBlock, getBlockOrder } =
select( blockEditorStore );
const blockOrder = getBlockOrder( clientId );

// Get the indexes of columns for which removal is prevented.
// The highest index will be used to determine the minimum column count.
const preventRemovalBlockIndexes = innerBlocks.reduce(
( acc, block, index ) => {
if ( ! canRemoveBlock( block.clientId ) ) {
const preventRemovalBlockIndexes = blockOrder.reduce(
( acc, blockId, index ) => {
if ( ! canRemoveBlock( blockId ) ) {
acc.push( index );
}
return acc;
Expand All @@ -73,7 +69,7 @@ function ColumnInspectorControls( {
);

return {
count: getBlockCount( clientId ),
count: blockOrder.length,
canInsertColumnBlock: canInsertBlockType(
'core/column',
clientId
Expand Down

0 comments on commit 6e85888

Please sign in to comment.