Skip to content

Commit

Permalink
Revert getBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Jan 29, 2024
1 parent fc87b2c commit 45aeb7a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/block-editor/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,11 @@ export function getBlockAttributes( state, clientId ) {
* @return {Object} Parsed block object.
*/
export function getBlock( state, clientId ) {
return state.blocks.tree.get( clientId ) ?? null;
if ( ! state.blocks.byClientId.has( clientId ) ) {
return null;
}

return state.blocks.tree.get( clientId );

This comment has been minimized.

Copy link
@jsnajdr

jsnajdr Jan 29, 2024

Member

Why did you have to revert this?

This comment has been minimized.

Copy link
@ellatrix

ellatrix Jan 29, 2024

Author Member

I misread it: one is getting from the tree, the other byClientId

This comment has been minimized.

Copy link
@jsnajdr

jsnajdr Jan 30, 2024

Member

But maybe it was right to start .get-ting only from the tree. If I understand this complex reducer correctly, all the state.blocks sub-maps (.tree, .attributes, .byClientId and .order) should always have the same keys, only different values. @youknowriad should know best.

This comment has been minimized.

Copy link
@youknowriad

youknowriad Jan 30, 2024

Contributor

yes, they should all have the same keys, the tree is a denormalization for performance reasons.

}

export const __unstableGetBlockWithoutInnerBlocks = createSelector(
Expand Down

0 comments on commit 45aeb7a

Please sign in to comment.