From d3c08197eb89beb75f39ab21be401fbe490bd02c Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 27 Apr 2026 10:19:41 +0000 Subject: [PATCH] Stop CleverPush SDK from breaking Shopware in-page anchor clicks 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 --- src/Resources/views/storefront/base.html.twig | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/src/Resources/views/storefront/base.html.twig b/src/Resources/views/storefront/base.html.twig index b4155db..96241ae 100644 --- a/src/Resources/views/storefront/base.html.twig +++ b/src/Resources/views/storefront/base.html.twig @@ -4,6 +4,86 @@ {{ parent() }} {% if config('CleverPushShopwarePlugin.config.channelId') is not empty %} + {# + CP-11185: The CleverPush SDK installs a delegated global click handler + that calls preventDefault() and stopImmediatePropagation() on every + click it considers "handleable". For Shopware-internal anchor links + (e.g. the product review tab via href="#review-tab-..." with + data-remote-click="true") this incorrectly cancels the native + tab-switch / hash navigation. + + Until the SDK exposes finer-grained shouldHandle() rules, we install + our own bubble-phase delegated listener on `document` BEFORE the + async CleverPush loader runs. Because click listeners on the same + target fire in registration order, ours fires first and uses + stopImmediatePropagation() to prevent the SDK's later-registered + handler (and any window-level fallback) from seeing the event. + + We do this only for elements that Shopware (or themes built on it) + uses for in-page navigation, so legitimate CleverPush tracking on + outbound / non-anchor clicks keeps working. + #} + {% endif %} {% endblock %}