Stop CleverPush SDK from breaking Shopware in-page anchor clicks (CP-11185)#5
Open
snuricp wants to merge 3 commits into
Open
Stop CleverPush SDK from breaking Shopware in-page anchor clicks (CP-11185)#5snuricp wants to merge 3 commits into
snuricp wants to merge 3 commits 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.
iboruch
requested changes
May 26, 2026
@iboruch I tried pushing a fix, but I’m running into permission issues. One possible approach would be to narrow the selector scope. Instead of targeting the entire `a[href^="#"]`, we could update it to `a[href^="#"][data-remote-click]`.
|
|
@harkeshkumar196 you are working on this? #5 (comment) |
|
Done @amitsingh8899 Please check. |
iboruch
approved these changes
Jun 12, 2026
akshay-g-jadhav
approved these changes
Jun 16, 2026
iboruch
approved these changes
Jun 16, 2026
akshay-g-jadhav
approved these changes
Jun 17, 2026
namdev-jagtap
approved these changes
Jun 17, 2026
paavan-cleverpush
approved these changes
Jun 19, 2026
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 so the PDP review tab opens and unexpected back navigation stops. Does this by wrapping document click listeners before the SDK loads, keeping outbound click handling intact. Ref: CP-11185
src/Resources/views/storefront/base.html.twigbefore the async CleverPush loader.Document.prototype.addEventListenerto wrap document click listeners and skip internal targets:a[href^="#"][data-remote-click],.product-detail-reviews-link.Written for commit 48a3a09. Summary will update on new commits.