-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Improve pattern rendering performance in the inserter #66053
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: -3 B (0%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
); | ||
} ) } | ||
{ shownPatterns.length < blockPatterns.length && ( | ||
<BlockPatternPlaceholder /> | ||
) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR removes the flickering when selecting blocks completely for me. 🥇
I just need help in understanding the logic changes.
In trunk, a BlockPatternPlaceholder
is rendered in the map()
callback for each block pattern not in shownPatterns
.
Here, it's a single BlockPatternPlaceholder
if shownPatterns
length is less than blockPatterns length.
Is that right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The block pattern renders about 20
patterns per page, and the shownPatterns are 0, 5, 10, 15 and 20 (async)
and the BlockPatternPlaceholder
is rendered for every pattern that is not shown (20 times initially, then 15 etc..)
When it was first introduced here, its not given any height. I assume placeholder introduced to occupy space for the pattern when it is not rendered yet.
But in a later change, the placeholder is set with 100% height.
In the current state, it is unnecessary to render 20 empty blocks with 100% height, instead rendering one single placeholder block is enough to show empty space in the initial view and until there are patterns to render. (That's what my understanding of the placeholder pattern)
It is shown until complete list of patterns are rendered and removed after.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have created #66114 and I think it improves the rendering much better.
Closing this since #66159 fixes the issue. |
What?
fixes: #65920
It fixes the re-rendering by directly rendering the
shownPatterns
instead of conditionally rendering allblockPatterns
Even this triggers a re-render, but since a pattern preview is memoized, it doesn't cause pattern to render again.
Before:
After:
Testing Instructions