Skip to content

refactor: centralize nested owner content-type resolution in base preview element - #319

Merged
rickbutterfield merged 1 commit into
v5/devfrom
v5/refactor/centralize-owner-contenttype
Jul 8, 2026
Merged

refactor: centralize nested owner content-type resolution in base preview element#319
rickbutterfield merged 1 commit into
v5/devfrom
v5/refactor/centralize-owner-contenttype

Conversation

@rickbutterfield

Copy link
Copy Markdown
Owner

Summary

Moves observeOwnerContentType() from the Block Grid view's setupContextObservers() into the shared BlockPreviewBaseElement constructor, 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 RenderGridBlock looks the block-editor property up on documentTypeUnique, 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 — call observeOwnerContentType() from the base constructor's BLOCK_PREVIEW_CONTEXT callback.
  • block-grid-preview.custom-view.element.ts — remove the explicit call.

The observeOwnerContentType() method body is unchanged (keeps setDocumentTypeUnique propagation 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 use documentTypeUnique server-side.

Tests

Full web-test-runner suite 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.

Note: the comment in nested-owner-contenttype-resolution.test.ts still describes the resolution as "Block Grid only"; that's now slightly stale (the wiring is shared) but the test itself remains Grid-scoped. Left untouched to keep this diff to the two source files.

🤖 Generated with Claude Code

…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>
@rickbutterfield
rickbutterfield merged commit ebd4db5 into v5/dev Jul 8, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant