fix: Render RTE block previews nested in a side-panel modal (#300)#302
Merged
Conversation
18e1fb5 to
5401972
Compare
RTE block previews stayed blank (raw <umb-rte-block>) when the rich text field belonged to a block edited in a side-panel modal — e.g. a Rich Text property on a block nested in a Block Grid/List. Root cause: the RTE custom view set up its block entry/manager-context observation from handleWorkspaceData(), which only runs once UMB_DOCUMENT_WORKSPACE_CONTEXT resolves. Inside a block-edit modal there is no document workspace context, so handleWorkspaceData() — and therefore observeBlockValue() — never ran, leaving contentUdi/blockEditorAlias empty and producing an empty (but error-free) preview. The try/catch fallback in Fix: observe the RTE entry/manager contexts independently of the workspace (they are always available to the block view) by calling observeBlockValue() from setupContextObservers(), guarded so it subscribes only once. unique / documentTypeUnique still resolve via the shared BlockPreview context. Also only subscribe to the manager once contentUdi is known, matching the Block List/Grid views. Verified live (Umbraco 17.5): the embedded card preview now renders inside the tiptap editor, with Block Grid (30/30) and Block List previews unaffected. Adds a Playwright regression test plus a renderedCount assertion so the empty-but-error-free failure mode is actually caught. Note: the compiled wwwroot bundle had not been rebuilt since 5.4.0, so this also re-bundles the previously-merged 5.4.x source fixes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
5401972 to
c465172
Compare
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.
Fixes #300 (and the Rich Text / nested half of #294).
Problem
RTE block previews stayed blank (raw
<umb-rte-block>, no error) when the rich text field belonged to a block edited in a side-panel modal — e.g. a Rich Text property on a block nested in a Block Grid/List.Root cause
The RTE custom view set up its block entry/manager-context observation from
handleWorkspaceData(), which only runs onceUMB_DOCUMENT_WORKSPACE_CONTEXTresolves. Inside a block-edit modal there is no document workspace context, sohandleWorkspaceData()— and thereforeobserveBlockValue()— never ran.contentUdi/blockEditorAliasstayed empty and the preview rendered nothing (with no error). Thetry/catchfallback in#observeDocumentWorkspacenever fired becauseconsumeContextdoes not throw.Fix
Observe the RTE entry/manager contexts independently of the workspace (they are always available to the block view) by calling
observeBlockValue()fromsetupContextObservers(), guarded so it subscribes only once.unique/documentTypeUniquestill resolve via the shared BlockPreview context. Also only subscribe to the manager oncecontentUdiis known, matching the Block List/Grid views.Verification
Verified live against the test site (Umbraco 17.5): the embedded card preview now renders inside the tiptap editor in the modal; Block Grid (30/30) and Block List previews are unaffected, zero preview errors.
renderedCountcheck so the empty-but-error-free failure mode (the actual Block Grid area previews can render before layoutAreas are available in 5.4.0 #293/Previews are no longer rendering in nested Block Lists when editing the parent block in 5.4.0 #294/RTE blocks not rendered in backoffice after 5.4.x refactor (regression from 5.2.1) #300 symptom) is caught.Note on the bundle
The compiled
wwwrootbundle had not been rebuilt since 5.4.0, so this also re-bundles the previously-merged 5.4.x source fixes. The companion PR adds a frontend build to the release workflow so this can't recur.🤖 Generated with Claude Code