Skip to content

fix: nested Block Grid delete navigates to parent block (#312) - #316

Merged
rickbutterfield merged 3 commits into
v5/devfrom
v5/bugfix/312-nested-delete-navigates-parent
Jul 8, 2026
Merged

fix: nested Block Grid delete navigates to parent block (#312)#316
rickbutterfield merged 3 commits into
v5/devfrom
v5/bugfix/312-nested-delete-navigates-parent

Conversation

@rickbutterfield

Copy link
Copy Markdown
Owner

Fixes #312

Problem

Deleting a child element inside a nested Block Grid container reloads the backoffice and opens the parent container's workspace instead of deleting the child. Deleting a top-level block works fine.

Root cause

Each block preview is rendered inside an <a class="block-preview-edit" href="{block edit route}">. When a Block Grid block has areas, Umbraco renders the child block entries — including their action bars — inside that anchor. A guard cancels the anchor's navigation for action-bar clicks so they don't trigger the parent block's edit route.

That guard ran in the bubble phase. Umbraco 17.5 wraps action buttons in <umb-block-action>, which calls stopPropagation() on the click before it can bubble to the ancestor anchor — so the guard never ran and its preventDefault() never fired. stopPropagation() does not cancel the anchor's default navigation, so the browser followed the parent block's href, reloading into the parent workspace.

Bisected against Umbraco: reproduces on 17.5.2, works on 17.3.4, with byte-identical BlockPreview click-handling code — i.e. it is triggered by the 17.5 backoffice DOM change, not a BlockPreview regression. (The same code is present on v5/dev, v6/main, and the released 5.4.3, matching the reporter's environments.)

Fix

Add a capture-phase guard on the preview host that cancels the anchor's default navigation for block-action clicks (delete / copy / scale), while letting the edit button through so it can still open the block workspace. The capture phase runs before propagation can be stopped, so it works on 17.5+ and remains correct on earlier versions.

The decision is extracted into a pure isBlockActionNavigation(path) function and unit tested.

Testing

  • 16/16 frontend unit tests pass, including 5 new cases in nested-block-action-navigation.test.ts (17.5 umb-block-action wrapper, older no-wrapper action bar, plain body click, edit-button exception, scale handle).
  • .NET library builds clean in Release.
  • Manual end-to-end on Umbraco 17.5.2 (test site "Home"):
    • Delete nested "See our solutions" → confirm dialog → child is deleted, no page reload, no parent workspace
    • Edit pencil on the nested child → still opens the child block ✅

Notes

🤖 Generated with Claude Code

rickbutterfield and others added 3 commits July 4, 2026 10:12
Bumps the development test site from Umbraco 17.3.4 to 17.5.2 so it
exercises the current backoffice, where the nested Block Grid delete
regression (#312) reproduces.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…312)

Each block preview is rendered inside an <a class="block-preview-edit">
whose href opens that block's edit workspace. When a Block Grid block has
areas, Umbraco renders the child block entries - including their action
bars - inside that anchor, so a guard cancels the anchor's navigation for
action-bar clicks.

That guard ran in the bubble phase. Umbraco 17.5 wraps action buttons in
umb-block-action, which stops click propagation before it reaches the
ancestor anchor, so the bubble guard never ran and its preventDefault
never fired. stopPropagation does not cancel the anchor's default
navigation, so deleting a child block reloaded the backoffice into the
parent block's workspace instead of deleting the child.

Add a capture-phase guard on the preview host that cancels the anchor's
default navigation for block-action clicks (delete/copy/scale), while
letting the edit button through. Capture runs before propagation can be
stopped, so it works on 17.5+ and remains correct on earlier versions.
The decision is extracted into isBlockActionNavigation() and unit tested.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…version (#312)

The bubble-phase guard in _handleClick duplicated the action-detection
logic and had diverged from isBlockActionNavigation: it checked only
UUI-ACTION-BAR/UMB-BLOCK-SCALE-HANDLER (missing UMB-BLOCK-ACTION) and used
a separate edit-button check. Delegate to isBlockActionNavigation so both
the capture- and bubble-phase guards share a single source of truth. The
edit button now falls through to the existing link/default handling
instead of returning early, which is behaviourally equivalent (nothing is
prevented, so navigation proceeds as before). Drop the now-unused
UUIButtonElement import and rebuild the bundle.

Also revert umbraco-package.json to version 5.5.0-alpha; the previous
value (5.5.0--alpha.preview.4.g60bee1c) was an accidentally-committed
build-time GitVersioning stamp.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@rickbutterfield
rickbutterfield merged commit 74a739a into v5/dev Jul 8, 2026
5 checks passed
rickbutterfield added a commit that referenced this pull request Jul 8, 2026
…ete-navigates-parent

fix: nested Block Grid delete navigates to parent block (#312)
rickbutterfield added a commit that referenced this pull request Jul 8, 2026
The index.js/index.js.map from the #316 merge were v5 artifacts and
conflicted on cherry-pick. Regenerate them from the merged TypeScript
source against v6 (6.1.0-alpha) so the shipped bundle matches the source.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant