Stop CleverPush SDK from breaking Shopware in-page anchor clicks (CP-11185)#5
Draft
Stop CleverPush SDK from breaking Shopware in-page anchor clicks (CP-11185)#5
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>
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.
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.