-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Inserter: patterns refresh when selecting different blocks #65920
Comments
Same here. Just in case, I've added it to the 6.7 board, but feel free to remove if anyone thinks it's more of an enhancement idea. |
Let's reclassify it as a bug. All enhancements should be removed from the 6.7 board at this point, and I agree that it feels very "buggy". |
I feel like this may be a duplicate of #65833? 🤔 |
Definitely related, but I do not feel it's a duplicate. I added more testing feedback in that ticket. |
I might be missing something obvious, but this might be the expected behavior. When clicking around the page, we also move the focus to different blocks. Some blocks don't allow inserting patterns, thus it shows "no results." I think this becomes more visible because we no longer close the inserter when moving focus. I agree that the UI and the wording are confusing and feel "buggy," but I'm not sure what the expected behavior should be 🤔. Someone more familiar with the recent changes might be able to verify whether this is indeed a bug. 🙏 |
I am not sure how to achieve this from a technical standpoint, but the pattern panel should only visibly update if the available selection of patterns needs to change. Right now, it visually refreshes every time you click on something, even if the patterns that are available to the user do not actually change. |
For example, in the video below, IMO the pattern panel should not visually refresh when clicking on the two blocks since the patterns that are available to the user do not change. pattern-refreshing.mp4 |
I was just looking at #66053 and I'm also not sure how to do this. Memoizing the incoming block and shown patterns, or abstracting the list into a separate component doesn't seem to mitigate the refresh. Somehow I think it's related to the AsyncList, passed to the component as shownPatterns. Notice how its value changes between identical blocks. The patterns end up being the same, but not before they're not 😄 2024-10-15.12.19.58.mp4For example, the flash completely goes away without it. E.g., <BlockPatternsList
ref={ scrollContainerRef }
/*
shownPatterns={ pagingProps.categoryPatternsAsyncList }
*/
shownPatterns={ pagingProps.categoryPatterns }
blockPatterns={ pagingProps.categoryPatterns } I'm not saying we remove it, only trying to identify the cause of the rerender trigger. 🤔 |
I think a part of the reason why we introduced |
The PR #66053 addresses the flickering problem.
Part of the fix is to render only the async list instead of entire pattern list, which is fixing the problem. |
I also believe |
Created #66114 which removes |
@WordPress/gutenberg-core Anyone with good experience of Specifically
|
Probably if we limit to 20 patterns. We should consider the |
The When the component gets an identical list (but a different array) on a render update, it explicitly tries to find out if some part of the list is already rendered, see the |
If the patterns.map( ( pattern ) => ( {
...pattern,
get blocks() {
return getParsedPattern( pattern ).blocks;
},
} ) ); where even identical patterns get transformed to non-identical objects. It could help to memoize these mapped patterns with a weakmap: Then the flashes should go away. I can try it out in the next 24 hours. |
#66159 is fixing this for me. The patterns list is stable and doesn't rerender when switching between selected blocks. But locally I see another strange bug, I wonder if anyone else sees it, too: There is a really big vertical space between the patterns in the pattern list, each item occupies the entire height of the viewport. It's caused by the |
Using 6.7 beta 1, I noticed that if I have the patterns tab open for the Inserter, it seems to be regularly re-rendering the list of patterns whenever I am clicking around the page. This sometimes leads to a "no results" similar to what's described here #65833
refreshing.inserter.mov
I am noting this as an enhancement as something to smooth out but it feels like a bug in many ways :)
The text was updated successfully, but these errors were encountered: