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

Block Editor: Don't memoize 'getContentLockingParent' and 'getParentSectionBlock' selectors #65649

Merged
merged 2 commits into from
Sep 25, 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
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
Loading