Stop CleverPush SDK from breaking Shopware in-page anchor clicks (CP-11185)#5
Stop CleverPush SDK from breaking Shopware in-page anchor clicks (CP-11185)#5snuricp wants to merge 1 commit into
Conversation
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>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default mode and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit d3c0819. Configure here.
| } else if (typeof event.stopPropagation === 'function') { | ||
| event.stopPropagation(); | ||
| } | ||
| }, false); |
There was a problem hiding this comment.
Guard over-blocks all document-level handlers, not just CleverPush
Medium Severity
Calling stopImmediatePropagation() on document in the bubble phase blocks ALL subsequently-registered document-level and window-level click handlers—not just CleverPush's. Because the inline script runs before any async/deferred JavaScript, this affects every other tool that uses document-level delegation for click tracking (e.g., Google Analytics, Matomo, Hotjar, or other Shopware plugins). The a[href^="#"] selector is especially broad, matching every hash link on the page including common href="#" JavaScript-action anchors, making silent breakage of analytics or other plugins likely.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit d3c0819. Configure here.


Problem
On Shopware 6 product detail pages, clicking the review stars / review link (a standard Shopware link with
href="#review-tab-..."anddata-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 whoseshouldHandle(e)is too permissive. Whenever it matches, the handler runs: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
shouldHandlehere. Instead, the Twig template now emits a tiny inline guard before the async loader.The guard registers a delegated
clicklistener ondocument(bubble phase). Because listeners on the sameEventTargetfire in registration order, ours runs before the SDK's later-registered handler. For elements that match a conservative "Shopware-internal navigation" selector list it callsstopImmediatePropagation()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'sRemoteClickPlugin[data-bs-toggle],[data-toggle]– Bootstrap 5 / 4 toggles (tabs, collapses, modals).product-detail-reviews-link– the specific review link called out in the ticketOutbound links and other clicks remain handled by CleverPush as before, so push-notification UX is preserved.
Files changed
src/Resources/views/storefront/base.html.twigManual test plan
RemoteClickPluginactivates) and the URL hash becomes#review-tab-.... No back-navigation to the category page.Refs CP-11185.
Linear Issue: CP-11185
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
src/Resources/views/storefront/base.html.twigbefore the async CleverPush loader.a[href^="#"],[data-remote-click],[data-bs-toggle],[data-toggle],.product-detail-reviews-link.Written for commit d3c0819. Summary will update on new commits.