Skip to content

fix: Prevent Block Grid area previews rendering before layoutAreas are available#295

Merged
rickbutterfield merged 2 commits into
v5/devfrom
v5/bugfix/293-block-grid-areas-timing
Jun 17, 2026
Merged

fix: Prevent Block Grid area previews rendering before layoutAreas are available#295
rickbutterfield merged 2 commits into
v5/devfrom
v5/bugfix/293-block-grid-areas-timing

Conversation

@rickbutterfield

Copy link
Copy Markdown
Owner

Summary

Fixes #293

Resolves a timing regression introduced in 5.4.0 where layout blocks with Areas could render an incomplete preview (empty Areas) if UMB_BLOCK_GRID_MANAGER_CONTEXT fired before layoutAreas arrived from UMB_BLOCK_GRID_ENTRY_CONTEXT.

The issue: the manager context fires renderBlockPreview() guarded by !this._htmlMarkup && !this._isLoading. If it fires before layoutAreas are available, #filterLayouts() produces empty area items, the API returns a BlockGridItem with empty Areas, and _htmlMarkup is set. When layoutAreas later arrives in observeBlockValue(), nothing re-triggers the render because markup already exists.

Two-part fix:

  • #observeBlockPropertyValue: defer the initial render when areas are configured (areas.length > 0) but layoutAreas have not arrived yet. The render is left to observeBlockValue once layout areas are available.
  • observeBlockValue: trigger a re-render when layoutAreas transitions from undefined to a value, so any block that received an incomplete early render is refreshed with full area content.

Also applies the contentUdi guard (only subscribe to the manager context once contentUdi is non-empty) to prevent a parallel issue where an empty contentUdi on the first entry-context emission could lock the manager subscription into producing an empty blockGridValue.

Test plan

  • Add a layout block with one or more Areas to a Block Grid property
  • Place child blocks inside the areas
  • Verify the preview renders with populated area content on first load
  • Verify resizing the block still re-renders correctly
  • Verify blocks without areas are unaffected

🤖 Generated with Claude Code

…e available (#293)

Fixes a timing regression introduced in 5.4.0 where blocks with Areas could
render an incomplete preview (empty Areas) if UMB_BLOCK_GRID_MANAGER_CONTEXT
fired before layoutAreas arrived from UMB_BLOCK_GRID_ENTRY_CONTEXT.

Two-part fix:
- #observeBlockPropertyValue: defer the initial render when areas are
  configured but layoutAreas have not arrived yet, instead of rendering
  with empty area items.
- observeBlockValue: trigger a re-render when layoutAreas first become
  available (prevLayoutAreas undefined → real value) so blocks that did
  receive an incomplete early render are refreshed with full area content.

Also applies the contentUdi guard (only subscribe to manager context once
contentUdi is non-empty) to prevent a parallel issue where an empty contentUdi
on the first entry-context emission could lock the manager subscription into
returning an empty blockGridValue.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

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 addresses a timing regression in Block Grid previews where layout blocks with configured Areas can render before layoutAreas are available, resulting in previews that permanently omit nested area content.

Changes:

  • Defers the initial preview render when Areas are configured but layoutAreas are not yet available.
  • Attempts to trigger a preview re-render when layoutAreas first arrive.
  • Avoids subscribing to the Block Grid manager context until contentUdi is non-empty to prevent an “empty value” lock-in.

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

- Rebuild blockGridValue.layout before re-rendering on layoutAreas arrival
  so callPreviewApi() sends updated area data, not the stale empty layout
- Remove _htmlMarkup requirement from the layoutAreas re-render condition so
  the deferred case (initial render skipped) is also handled
- Guard the re-render on #managerObserved so it only fires once contentData
  is available from the manager context
- Fix contents.findIndex() to use (contents ?? []).findIndex() for null safety

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@rickbutterfield rickbutterfield merged commit 0e35f02 into v5/dev Jun 17, 2026
8 checks passed
@rickbutterfield rickbutterfield deleted the v5/bugfix/293-block-grid-areas-timing branch June 17, 2026 08:58
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