Skip to content

Fix: newly added Block Grid area blocks never render a preview - #323

Open
rickbutterfield wants to merge 1 commit into
v6/devfrom
claude/issue-322-mtnvnb
Open

Fix: newly added Block Grid area blocks never render a preview#323
rickbutterfield wants to merge 1 commit into
v6/devfrom
claude/issue-322-mtnvnb

Conversation

@rickbutterfield

Copy link
Copy Markdown
Owner

Summary

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

Root cause: Umbraco's UmbBlockGridEntryContext derives layoutAreas as layout?.areas (verified against the published @umbraco-cms/backoffice@18.0.0 source). 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. #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

  • tsc --noEmit passes
  • npm run build succeeds and bundle reflects the change
  • Manual verification in the test site: add a new area-carrying block to a Block Grid property without saving and confirm the preview renders with the "Add new Layout" button, and that existing saved blocks with area content still render correctly (Block Grid area previews can render before layoutAreas are available in 5.4.0 #293 regression check)

Generated by Claude Code

… forever for layoutAreas (#322)

A newly added, unsaved block's layout entry has no `areas` key at all —
Umbraco's UmbBlockGridEntryContext derives layoutAreas as `layout?.areas`,
which stays undefined until content is added to an area or the document
is saved. The #293 fix deferred rendering until layoutAreas arrived, which
meant new area-carrying blocks never rendered a preview at all, leaving
the area's create button unreachable.

#filterLayouts() already defaults each area's items to [] when layoutAreas
is missing, so it's safe to render immediately; the existing re-render
trigger in observeBlockValue still refreshes the preview once real
layoutAreas data does arrive, preserving the #293 fix.

Rebuilt the backoffice bundle to include the change.
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.

2 participants