refactor: centralize nested owner content-type resolution in base preview element - #319
Merged
Merged
Conversation
…ment observeOwnerContentType() resolves the content type that owns a nested block-editor property (the parent element type) so the server can find the property alias — without it a nested Block Grid preview renders "The property type is invalid." (#293/#291). It was wired only into BlockGridPreviewCustomView.setupContextObservers(), so any other view that needs it — or a future view — would silently miss it. Move the call into the shared BlockPreviewBaseElement constructor so every view (grid, list, single, rich text) gets it, and drop the now-redundant call from the grid view. No behavioural change: the method body (setDocumentTypeUnique propagation and the late-arriving-workspace re-render) is untouched; it is a no-op for top-level previews and for views that don't use documentTypeUnique server-side. Full web-test-runner suite passes (16/16). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Summary
Moves
observeOwnerContentType()from the Block Grid view'ssetupContextObservers()into the sharedBlockPreviewBaseElementconstructor, so every preview view (grid, list, single, rich text) resolves the nested owner content type from one place. Drops the now-redundant call from the grid view.This is a consistency/hardening refactor, not a bug fix — the nested-Grid "The property type is invalid." bug (#293/#291) is already fixed on
v5/dev. The refactor removes the footgun that caused it:observeOwnerContentType()was wired into a single view, so any other view that needs it (or a new view) would silently miss it.Why
Server-side, only
RenderGridBlocklooks the block-editor property up ondocumentTypeUnique, so only Grid can return "The property type is invalid." when nested. That's why the fix was Grid-only. But wiring the resolver per-view is fragile — centralizing it in the base means coverage can't regress by omission.Change
block-preview-base.element.ts— callobserveOwnerContentType()from the base constructor'sBLOCK_PREVIEW_CONTEXTcallback.block-grid-preview.custom-view.element.ts— remove the explicit call.The
observeOwnerContentType()method body is unchanged (keepssetDocumentTypeUniquepropagation and the late-arriving-workspace re-render). It's a no-op for top-level previews (no block workspace) and for views that don't usedocumentTypeUniqueserver-side.Tests
Full
web-test-runnersuite passes (16/16), including the existing Grid owner-content-type resolution test — confirming Grid still resolves the owner type now that it comes from the base.🤖 Generated with Claude Code