Remove duplicate hidden post from Query Loop block#73669
Remove duplicate hidden post from Query Loop block#73669Utsav-Ladani wants to merge 2 commits intoWordPress:trunkfrom
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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @caseymilne. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. At least one To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
SirLouen
left a comment
There was a problem hiding this comment.
@Utsav-Ladani have you researched which was the original purpose of that isHidden property?
This is important. I would recommend doing the same every time you want to remove something from the codebase. Context is key when it comes to large, old projects. cc @andrewserong, @ntsekouras, I think you both worked on this area a while back. |
|
Thanks for the ping! Things might have changed as the original code to add the duplication was added quite a long time ago, but it was added to ensure that there's a seamless and non-flickery behaviour when users click between the different instances of items within the query loop in the editor. It was most visible on loops that involved background colors or lots of blocks, or things like that where the flickering is more obvious. Anecdotally, with this PR checked out, I can see the flicker again when clicking between instances of a query loop (i.e. clicking between the first and second posts within the editor canvas). The flicker is intrusive, but unfortunately also very brief so in a video demoing it, it doesn't quite capture it properly. Hopefully this video captures it a little: 2025-12-02.15.02.32.mp4 |
|
Yeah, this code is about the flickering that occurs when we change the active block context and we can't just remove it. You could explore a possible different way for this, but I have no suggestions of a better way to achieve this. |
|
Thanks @andrewserong for catching the issue. This flicker is happening when used a group block with top-bottom padding. Earlier, I tested this bug with templates which don't have padding, so didn't catch the issue. However, I noticed same issue with
The reason behind this flicker is that the block rendered twice – first w/ @ntsekouras I backtracked this behavior and found that a component named gutenberg/packages/block-editor/src/hooks/utils.js Lines 572 to 598 in 48a6e8a I tried using |
SirLouen
left a comment
There was a problem hiding this comment.
@Utsav-Ladani we need to think on a better workaround than using useLayoutEffect to sort this out.
|
@SirLouen I have an another solution which seems to break the However, we are always using fixed number of I pushed my solution to this PR in case you wanna test. |
|
Hey @ellatrix, any insight on the above approach? |

What?
Closes #58889
Remove duplicate hidden post from Query Loop block in block editor to keep same post order as frontend. Check #58889 for more details.
Why?
Address the CSS selector issue and ensure consistent UI across both the Block Editor and the Frontend.
How?
Conditionally rendering block or preview based on active block context instead of always rendering preview.
Testing Instructions
Query Loopblock.