fix: Prevent Block Grid area previews rendering before layoutAreas are available#295
Merged
Merged
Conversation
…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>
Contributor
There was a problem hiding this comment.
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
layoutAreasare not yet available. - Attempts to trigger a preview re-render when
layoutAreasfirst arrive. - Avoids subscribing to the Block Grid manager context until
contentUdiis 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_CONTEXTfired beforelayoutAreasarrived fromUMB_BLOCK_GRID_ENTRY_CONTEXT.The issue: the manager context fires
renderBlockPreview()guarded by!this._htmlMarkup && !this._isLoading. If it fires beforelayoutAreasare available,#filterLayouts()produces empty area items, the API returns aBlockGridItemwith emptyAreas, and_htmlMarkupis set. WhenlayoutAreaslater arrives inobserveBlockValue(), nothing re-triggers the render because markup already exists.Two-part fix:
#observeBlockPropertyValue: defer the initial render when areas are configured (areas.length > 0) butlayoutAreashave not arrived yet. The render is left toobserveBlockValueonce layout areas are available.observeBlockValue: trigger a re-render whenlayoutAreastransitions fromundefinedto a value, so any block that received an incomplete early render is refreshed with full area content.Also applies the
contentUdiguard (only subscribe to the manager context oncecontentUdiis non-empty) to prevent a parallel issue where an emptycontentUdion the first entry-context emission could lock the manager subscription into producing an emptyblockGridValue.Test plan
🤖 Generated with Claude Code