Skip to content

Commit

Permalink
Block Editor: Don't memoize 'getContentLockingParent' and 'getParentS…
Browse files Browse the repository at this point in the history
…ectionBlock' selectors (WordPress#65649)


Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: youknowriad <[email protected]>
  • Loading branch information
3 people authored Sep 25, 2024
1 parent cb44f51 commit d21a2d1
Showing 1 changed file with 21 additions and 45 deletions.
66 changes: 21 additions & 45 deletions packages/block-editor/src/store/private-selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,69 +474,45 @@ export function getExpandedBlock( state ) {
* with the provided client ID.
*
* @param {Object} state Global application state.
* @param {Object} clientId Client Id of the block.
* @param {string} clientId Client Id of the block.
*
* @return {?string} Client ID of the ancestor block that is content locking the block.
*/
export const getContentLockingParent = createSelector(
( state, clientId ) => {
let current = clientId;
let result;
while (
! result &&
( current = state.blocks.parents.get( current ) )
) {
if ( getTemplateLock( state, current ) === 'contentOnly' ) {
result = current;
}
export const getContentLockingParent = ( state, clientId ) => {
let current = clientId;
let result;
while ( ! result && ( current = state.blocks.parents.get( current ) ) ) {
if ( getTemplateLock( state, current ) === 'contentOnly' ) {
result = current;
}
return result;
},
( state ) => [
state.blocks.parents,
state.blockListSettings,
state.settings.templateLock,
]
);
}
return result;
};

/**
* Retrieves the client ID of the parent section block.
*
* @param {Object} state Global application state.
* @param {Object} clientId Client Id of the block.
* @param {string} clientId Client Id of the block.
*
* @return {?string} Client ID of the ancestor block that is content locking the block.
*/
export const getParentSectionBlock = createSelector(
( state, clientId ) => {
let current = clientId;
let result;
while (
! result &&
( current = state.blocks.parents.get( current ) )
) {
if ( isSectionBlock( state, current ) ) {
result = current;
}
export const getParentSectionBlock = ( state, clientId ) => {
let current = clientId;
let result;
while ( ! result && ( current = state.blocks.parents.get( current ) ) ) {
if ( isSectionBlock( state, current ) ) {
result = current;
}
return result;
},
( state ) => [
state.blocks.parents,
state.blocks.order,
state.blockListSettings,
state.editorMode,
state.settings.templateLock,
state.blocks.byClientId,
getSectionRootClientId( state ),
]
);
}
return result;
};

/**
* Retrieves the client ID is a content locking parent
*
* @param {Object} state Global application state.
* @param {Object} clientId Client Id of the block.
* @param {string} clientId Client Id of the block.
*
* @return {boolean} Whether the block is a content locking parent.
*/
Expand Down

0 comments on commit d21a2d1

Please sign in to comment.