Block Editor: Show only the allowed patterns from top level blocks#30300
Conversation
|
Size Change: -3 B (0%) Total Size: 1.42 MB
ℹ️ View Unchanged
|
|
I don't think this is necessary. I think we just need to remove the early return from gutenberg/packages/block-editor/src/store/selectors.js Lines 1821 to 1823 in 94db813
|
@david-szabo97 I know but I thought this was part of the perf optimization in your PR. So you think it's okay to remove the early return and get the |
|
Right, it's safe to remove. And yes, that was an optimization but I wasn't aware of |
7afba8d to
69059f1
Compare
69059f1 to
7d36548
Compare
There was a problem hiding this comment.
This implementation only works for top-level blocks in patterns. If a pattern contains a block deep inside somewhere in its block tree, then it will still show up in the inserter. We need to recursively check for all blocks in the pattern.
For now, I'd go with this implementation and create a follow-up PR that solves this problem in a performance-friendly way. (I'll push a draft PR)
Description
Partially fixes: #23275
Currently patterns don't take into account the
allowed_block_typeswhich can result in showing block patterns in the Inserter and by clicking one the following happens:allowed_block_typesis checked during insertionThis is not a complete solution due to performance implications of pattern parsing for various actions. Ideally we need to find a performant way to recurse through all inner blocks of a block and check if the block is allowed or if is unregistered. For now we check the top level blocks of a pattern.
Testing instructions
allowed_block_typesin phppatternstab and observe the proper results