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

Columns: Replace some store selectors with 'getBlockOrder' #67991

Merged
merged 1 commit into from
Dec 14, 2024
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
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 ),
Copy link
Member Author

Choose a reason for hiding this comment

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

The getBlockCount uses getBlockOrder internally.

count: blockOrder.length,
canInsertColumnBlock: canInsertBlockType(
'core/column',
clientId
Expand Down
Loading