Skip to content

fix: newly added Block Grid area blocks never render a preview (#322) - #333

Open
rickbutterfield wants to merge 1 commit into
v6/devfrom
claude/review-comments-322-10z097
Open

fix: newly added Block Grid area blocks never render a preview (#322)#333
rickbutterfield wants to merge 1 commit into
v6/devfrom
claude/review-comments-322-10z097

Conversation

@rickbutterfield

Copy link
Copy Markdown
Owner

Summary

Fixes #322 — a newly added, unsaved Block Grid block with areas never renders a preview.

Why this is still happening on released 6.1.0: PR #323 already fixed this same bug, but only on v6/dev. v6/dev was merged into v6/main for the 6.1.0 release before #323 landed, so the fix never made it into a release — matching the original report (6.1.0) and the two follow-up comments on #322 reporting the bug persists on 5.5.0/17.6.0 (and that downgrading to 5.4.1 works around it).

Root cause: Umbraco's UmbBlockGridEntryContext derives layoutAreas as layout?.areas. A brand-new block is created with an empty partialLayoutEntry: {}, so its layout entry has no areas key at all — layoutAreas stays undefined until content is added into an area or the document is saved and reloaded.

The #293 fix added a guard that deferred the initial preview render whenever a block had configured areas but layoutAreas hadn't arrived yet, to avoid a transient incomplete render. For brand-new blocks that guard never releases, so the preview stays permanently blank and the area's "Add new Layout" button (part of the server-rendered markup) is unreachable.

Fix: Removed the defer/early-return in #observeBlockPropertyValue, mirroring #323 exactly. #filterLayouts() already defaults each area's items to [] when layoutAreas is missing, so rendering immediately is safe and correct for new blocks. The existing re-render trigger in observeBlockValue (fired when layoutAreas transitions from absent to present) is untouched, so the #293 fix for saved blocks with a content/settings-vs-layoutAreas race is preserved.

  • src/Umbraco.Community.BlockPreview.UI/src/blockEditor/block-grid-preview.custom-view.element.ts — remove the defer guard
  • Rebuilt backoffice bundle (wwwroot/App_Plugins/...) to include the change

Test plan


Generated by Claude Code

Umbraco's UmbBlockGridEntryContext derives layoutAreas as layout?.areas.
A brand-new block starts with an empty layout entry, so layoutAreas stays
undefined until content is added to an area or the document is saved and
reloaded. The #293 guard deferred the initial render whenever a block had
configured areas but layoutAreas hadn't arrived yet, and for new blocks
that guard never released, leaving the preview permanently blank.

Remove the defer/early-return so new blocks render immediately;
#filterLayouts() already defaults each area's items to [] when
layoutAreas is missing, and the existing re-render trigger in
observeBlockValue still fires once real layoutAreas data arrives,
preserving the #293 fix for saved blocks.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J3ybE1j7L5X32L7k4mvgYz
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.

Newly added blocks with areas never render a preview — deferred render waits for layoutAreas that only exist after save

2 participants