Skip to content

Block preview shows wrong content for blocks using AssignedContentItem in blueprint editor #271

@deanleigh

Description

@deanleigh

Which Umbraco.Community.BlockPreview version are you using?

5.3.2

Which Umbraco version are you using? For example: 10.4.0 - don't just write v10

17.1.0

Bug summary

When editing a Document Blueprint in Settings > Document Blueprints, blocks that read from the parent document via Umbraco.AssignedContentItem display content from a random existing published page instead of the blueprint's own property values.

For example, a block that renders @currentPage.PageTitle shows "The Moorish Treasures of Andalucía" (from an existing published page) instead of [Page Title] (the blueprint's actual stored value).

Image Image

Blocks with their own self-contained content (e.g. Rich Text Editor blocks) render correctly. The issue only affects blocks that reach "upward" to the parent document for their data via AssignedContentItem.

The created document from the blueprint has the correct values — this is a preview-only issue.

Steps to reproduce

  1. Create a document type (e.g. "Tailored Tour") with a block grid property and page-level properties (pageTitle, pageDescription)
  2. Create a block grid element type (e.g. "Feature - Page Title and Description") with no stored properties — its Razor partial reads from Umbraco.AssignedContentItem:
    @{
        if (Umbraco.AssignedContentItem is not IContentHeadingDefault currentPage) return;
    }
    <h1>@currentPage.PageTitle</h1>
    <p>@currentPage.PageDescription</p>
  3. Create a real content page of that document type with pageTitle = "The Moorish Treasures of Andalucia"
  4. Create a Document Blueprint of the same type with pageTitle = "[Page Title]" (placeholder text)
  5. Add the block to the blueprint's block grid
  6. Expected: Block grid preview shows "[Page Title]"
  7. Actual: Block grid preview shows "The Moorish Treasures of Andalucia" (from the existing content page)

The issue is in the AssignedContentItem resolution chain in UmbracoViewPage.cs:

  1. View model is BlockGridItem (not IPublishedContent) — skipped
  2. View model is not IContentModel — skipped
  3. Fallback: UmbracoContext.PublishedRequest.PublishedContent — resolves to an existing published page, not the blueprint
    Blueprints have IsBlueprint = true and are not in the published content cache. The fallback in step 3 picks up whatever was last in the published request context.

Expected result / actual result

When editing a Document Blueprint, the block grid SSR preview should resolve Umbraco.AssignedContentItem to the blueprint content, allowing blocks to read the blueprint's own property values.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions