Block switcher: don't get all parsed patterns when unopened#57020
Block switcher: don't get all parsed patterns when unopened#57020ellatrix wants to merge 1 commit into
Conversation
|
Size Change: +107 B (0%) Total Size: 1.71 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in c32fb23. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7195796165
|
|
|
||
| if ( | ||
| ! hasBlockStyles && | ||
| ! hasPossibleBlockTransformations && |
There was a problem hiding this comment.
Unfortunately we can't do this refactoring because we could end up with en empty Dropdown. This highlights an existing bug though because we should add the && ! hasPatternTransformation check here. If we have no styles or block transformations, but we have patterns, now we do not render the Dropdown.
There was a problem hiding this comment.
But it exists in trunk :D
There was a problem hiding this comment.
Ok, I guess we need lighter has* selectors?
There was a problem hiding this comment.
Yeah probably some has selectors. I actually introduced a private one yesterday - not for this case. We would need something that filters first by blockType and then parses, but what concerns me a bit is that with lazy loading the patterns parsing will have to be refactored anyway. So maybe wait a bit for these? 🤔
There was a problem hiding this comment.
But it exists in trunk :D
I opened a PR for the bug in trunk
What?
Currently we seem to be parsing a lot of patterns when simply showing the block switcher (when selecting a block), at least on the first call of
__experimentalGetPatternTransformItems. We should only call the__experimentalGetPatternTransformItemsselector when the dropdown is rendered.Maybe this also helps stabilise this metric because the first select will be heavy.
Why?
How?
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast