Skip to content

Stop CleverPush SDK from breaking Shopware in-page anchor clicks (CP-11185)#5

Draft
snuricp wants to merge 1 commit intomasterfrom
cursor/fix-global-click-handler-review-tab-af7c
Draft

Stop CleverPush SDK from breaking Shopware in-page anchor clicks (CP-11185)#5
snuricp wants to merge 1 commit intomasterfrom
cursor/fix-global-click-handler-review-tab-af7c

Conversation

@snuricp
Copy link
Copy Markdown

@snuricp snuricp commented Apr 27, 2026

Problem

On Shopware 6 product detail pages, clicking the review stars / review link (a standard Shopware link with href="#review-tab-..." and data-remote-click="true") fails to open the review tab in ~90% of cases and instead lets the browser navigate back to the previous category page.

Root cause (per CP-11185): the CleverPush loader script (https://static.cleverpush.com/channel/loader/{channelId}.js) installs a delegated global click handler whose shouldHandle(e) is too permissive. Whenever it matches, the handler runs:

e.preventDefault();
e.stopImmediatePropagation();
this.notify(...);

For Shopware-internal anchor links this kills Shopware's native hash/tab-switch logic. Disabling the plugin resolves it; removing direct listeners on the link does not (confirming a delegated global listener is the source).

Fix

This Shopware plugin only injects the remote loader, so we cannot patch shouldHandle here. Instead, the Twig template now emits a tiny inline guard before the async loader.

The guard registers a delegated click listener on document (bubble phase). Because listeners on the same EventTarget fire in registration order, ours runs before the SDK's later-registered handler. For elements that match a conservative "Shopware-internal navigation" selector list it calls stopImmediatePropagation() so the SDK's handler is never invoked for those clicks, leaving Shopware's element-level handlers (RemoteClickPlugin, Bootstrap toggles, native hash navigation) intact.

Selectors covered:

  • a[href^="#"] – any internal anchor
  • [data-remote-click] – Shopware's RemoteClickPlugin
  • [data-bs-toggle], [data-toggle] – Bootstrap 5 / 4 toggles (tabs, collapses, modals)
  • .product-detail-reviews-link – the specific review link called out in the ticket

Outbound links and other clicks remain handled by CleverPush as before, so push-notification UX is preserved.

Files changed

  • src/Resources/views/storefront/base.html.twig

Manual test plan

  1. Configure the plugin with a CleverPush Channel ID and load any Shopware 6 PDP that renders the review tab.
  2. Click the review stars / "X reviews" link.
  3. Expected: the review tab opens (Shopware's RemoteClickPlugin activates) and the URL hash becomes #review-tab-.... No back-navigation to the category page.
  4. Sanity-check: click any external/outbound link (not matching the selectors above) – CleverPush's normal click handling still runs.

Refs CP-11185.

Linear Issue: CP-11185

Open in Web Open in Cursor 

Summary by cubic

Prevents the CleverPush SDK from blocking Shopware in-page anchor clicks, fixing the PDP review tab not opening and unexpected back navigation. Keeps CleverPush handling for outbound clicks while allowing Shopware’s hash/tab logic to run. Ref: CP-11185

  • Bug Fixes
    • Injects a small inline guard in src/Resources/views/storefront/base.html.twig before the async CleverPush loader.
    • Adds a document-level click listener that runs first and stops propagation for internal navigation targets: a[href^="#"], [data-remote-click], [data-bs-toggle], [data-toggle], .product-detail-reviews-link.
    • Non-matching clicks still flow to the CleverPush handler.

Written for commit d3c0819. Summary will update on new commits.

The CleverPush loader script registers a delegated global click handler
that calls preventDefault() + stopImmediatePropagation() on clicks it
considers handleable. On Shopware 6 product detail pages this incorrectly
cancels the native review-tab navigation (href="#review-tab-...",
data-remote-click="true"), causing the click to fall through to the
browser's default behavior and navigate back to the previous page.

Until the SDK exposes a configurable shouldHandle() rule for
Shopware-internal anchors, install a small inline guard in the
storefront base template that runs before the async CleverPush loader.
The guard registers a delegated click listener on document that fires
before the SDK's later-registered handler and calls
stopImmediatePropagation() for clicks on Shopware-internal navigation
targets (a[href^="#"], [data-remote-click], [data-bs-toggle],
[data-toggle], .product-detail-reviews-link), so the SDK never sees
those events. Element-level handlers (RemoteClickPlugin, Bootstrap
toggles) fire in the target phase before this listener and are
unaffected.

Refs CP-11185

Co-authored-by: Sahel Nuri <snuricp@users.noreply.github.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.

2 participants