fix: resolve nodeKey for previews nested in block lists#298
Merged
Conversation
Block preview custom views resolved their document nodeKey by reading the
content/document workspace context. That context shares its alias
('UmbWorkspaceContext') with the block workspace context, and context
consumers stop at the first alias match by default. When a preview was
rendered inside another block, the nearer block workspace shadowed the
document workspace, so the lookup never resolved and the view fell back to
a session-global node-key cache — which was either empty (causing the
stylesheet request to fail Guid binding) or stale from a previously
visited node.
The four custom views (block list, single, grid, rich text) now pass
beyond alias matches via passContextAliasMatches, so nested previews
resolve the real document node directly.
Also removes now-dead code from BlockPreviewContext: the unused unique /
documentTypeUnique observables and the redundant settings plumbing (which
duplicated the settings fetch already done at startup).
Adds a web-test-runner regression test that mounts the list preview inside
a shadowing block workspace and asserts it resolves the document nodeKey.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Parametrize the issue #297 regression test across the block list, single, grid, and rich-text custom views (previously list-only). The rich-text view consumes UMB_DOCUMENT_WORKSPACE_CONTEXT (matched on getEntityType) with a flat contentTypeUnique, while the others use UMB_CONTENT_WORKSPACE_CONTEXT (matched on IS_CONTENT_WORKSPACE_CONTEXT) with structure.contentTypeUniques, so each gets the appropriate workspace fake. Also correct a stale comment in BlockPreviewContext describing the node-key cache fallback, and add a test-scoped tsconfig.test.json (plus @types/mocha) so the mocha globals in test files resolve without affecting the build tsconfig. Co-Authored-By: Claude Opus 4.8 (1M context) <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 #297 — block previews rendered inside a nested block list failed to resolve their
nodeKey, causing the stylesheet API call to fail (emptynodeKey→Guidbind error) or render against a stale node from a previously-visited page.Root cause
UMB_CONTENT_WORKSPACE_CONTEXT/UMB_DOCUMENT_WORKSPACE_CONTEXTandUMB_BLOCK_WORKSPACE_CONTEXTare all registered under the same context alias ('UmbWorkspaceContext'), distinguished only by a discriminator. Context consumers default to stopping at the first alias match. For a preview nested inside another block, the surrounding block workspace shadowed the document workspace, so the lookup never resolved — and the view fell back to a session-global node-key cache that was either empty or stale (the cross-page leak described in the issue).Fix
The four custom views (block list, single, grid, rich text) now use
passContextAliasMatcheson their workspace lookups, so nested previews pass the block workspace and resolve the real document node directly.Cleanup
Removed now-dead code from
BlockPreviewContext:unique/documentTypeUniqueobservables, andThe
getUnique/setUniquecache andobserveBlockWorkspaceFallbackare intentionally kept: they remain load-bearing for previews rendered inside a portaled block-edit modal, where no content/document workspace is reachable.Tests
Added a
@web/test-runnersetup (the UI project previously had none) and a regression test that mounts the list preview inside a shadowing block workspace and asserts it resolves the documentnodeKey. Confirmed it fails before the fix and passes after; a second test guards the non-nested case.🤖 Generated with Claude Code