Repository navigation
fix: return stable block clientId values for unchanged content - #528
Merged
Merged
Conversation
Contributor
🛝 WordPress PlaygroundBuilt from 242cb68 Opens GraphiQL with WPGraphQL and this build active. The "Content Blocks Demo" post has core blocks to query through |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #505.
Every block's
clientIdcame fromuniqid(), so the same query against unchanged content returned different IDs on every request. That breaks response caching, static regeneration diffs, and React keys built fromclientId/parentClientId.clientIdis now a hash of:clientIdplus its indexinnerHTMLIt stays the same until that block changes, and it keeps the 13-character hex format
uniqid()produced. Blocks pulled in from elsewhere (reusable blocks, template parts, post content) are seeded with the parent block's ID, so a reusable block used twice still gets unique IDs.Blocks returned through
wpgraphql_content_blocks_pre_resolve_blockswithout aclientIdfall back to a hash of the block alone. Before, they got a random ID. In that path, identical sibling blocks will share an ID, so filters that build their own block lists should setclientIdthemselves.Testing
parentClientIdpoints at a block in the response. Editing one block changes only that block's ID. It fails onmainand passes with this change.Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Assisting with reproducing the bug, the fix, and the test.