Skip to content

fix: resolve documentTypeUnique for Block Grid nested in an element type (#293, #291)#309

Merged
rickbutterfield merged 2 commits into
v5/devfrom
v5/bugfix/293-nested-element-grid-documenttype
Jul 1, 2026
Merged

fix: resolve documentTypeUnique for Block Grid nested in an element type (#293, #291)#309
rickbutterfield merged 2 commits into
v5/devfrom
v5/bugfix/293-nested-element-grid-documenttype

Conversation

@rickbutterfield

Copy link
Copy Markdown
Owner

Summary

Fixes the The property type is invalid. error when previewing a Block Grid nested inside an element type (issues #293 nested-element regression and #291).

A Block Grid preview needs two independent values:

  • nodeKey → the document being previewed (the page)
  • documentTypeUnique → the content type that declares the block-editor property

Since #297 the content-workspace lookup uses passContextAliasMatches to reach the root document. That is correct for nodeKey, but for a Block Grid property declared on a nested element type it resolved the root document type — which doesn't declare the nested property alias — so the server returned The property type is invalid.

Fix

  • Resolve documentTypeUnique from the nearest block workspace's element content type when nested, falling back to the document type at top level (observeOwnerContentType in the shared base element).
  • nodeKey resolution is unchanged, so Fails getting nodeKey in nested block lists #297 stays intact.
  • Block Grid only — the list, single and rich-text render paths don't use documentTypeUnique, so they're deliberately untouched.

Tests

  • New nested-owner-contenttype-resolution.test.ts: nested resolves to the element type, non-nested resolves to the document type, and a late-arriving block workspace correctly re-resolves.
  • Verified live in the test site: the nested Block Grid preview renders and the request now sends the element type key with a 200 response.

CI

  • New ci.yml runs the frontend (npm test) and .NET (dotnet test) suites on push/PR to v5/dev, v5/main, v6/dev, v6/main — previously the frontend tests ran nowhere and .NET tests ran only at release.
  • release.yml now runs the frontend tests before publishing.

🤖 Generated with Claude Code

…ype (#293, #291)

A Block Grid preview resolves two independent values: the nodeKey (the
document being previewed) and the documentTypeUnique (the content type that
declares the block-editor property). Since #297 the content-workspace lookup
passes beyond alias matches to reach the root document, which is correct for
nodeKey but wrong for documentTypeUnique when the Block Grid property lives on
an element type nested inside another block: it resolved the root document
type, so the server could not find the property alias on it and returned
"The property type is invalid."

Resolve documentTypeUnique from the nearest block workspace's element content
type when the preview is nested, falling back to the document type at top
level. nodeKey resolution is unchanged (#297 preserved). The fix is Block Grid
only: the list, single and rich-text render paths do not use documentTypeUnique.

Adds web-test-runner coverage (nested, non-nested, and late-arriving block
workspace ordering) and wires the frontend test suite into CI - a new ci.yml
runs both the frontend and .NET suites on push/PR to the long-lived branches,
and release.yml now runs the frontend tests before publishing.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Comment thread .github/workflows/ci.yml Fixed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes Block Grid preview requests when a Block Grid is nested inside an element type by resolving documentTypeUnique from the nearest block workspace’s owning element content type (while keeping nodeKey resolution rooted at the document workspace). It also adds regression tests for the nested owner-type behavior and introduces/updates GitHub Actions workflows to run frontend and .NET test suites in CI and release.

Changes:

  • Resolve documentTypeUnique from the nearest block workspace (element type) for nested Block Grid previews, with re-render on late owner-type arrival.
  • Add regression tests covering nested vs non-nested owner content type resolution (including late-arriving block workspace).
  • Add a CI workflow and update the release workflow to run frontend tests (including Playwright browser install) alongside .NET build/tests.

Reviewed changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Umbraco.Community.BlockPreview/wwwroot/App_Plugins/Umbraco.Community.BlockPreview/index.js Rebuilt plugin bundle including the nested owner content-type resolution behavior.
src/Umbraco.Community.BlockPreview.UI/src/blockEditor/block-preview-base.element.ts Adds owner content type observation and prefers it for documentTypeUnique when available.
src/Umbraco.Community.BlockPreview.UI/src/blockEditor/block-grid-preview.custom-view.element.ts Hooks owner content type observation into Block Grid preview setup.
src/Umbraco.Community.BlockPreview.UI/src/blockEditor/nested-owner-contenttype-resolution.test.ts New regression tests for nested owner content type resolution (and late-arrival correction).
.github/workflows/release.yml Runs Playwright install + frontend tests before building/publishing.
.github/workflows/ci.yml New CI workflow running frontend build/tests and .NET build/tests on pushes/PRs to long-lived branches.
Files not reviewed (1)
  • src/Umbraco.Community.BlockPreview/wwwroot/App_Plugins/Umbraco.Community.BlockPreview/index.js: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- ci.yml: add least-privilege 'permissions: contents: read' (CodeQL).
- nested-owner-contenttype-resolution.test.ts: stub fetchStylesheets() so
  the grid preview test doesn't make a real HTTP request (Copilot).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@rickbutterfield rickbutterfield merged commit 60bee1c into v5/dev Jul 1, 2026
9 checks passed
@rickbutterfield rickbutterfield deleted the v5/bugfix/293-nested-element-grid-documenttype branch July 1, 2026 13:23
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.

3 participants