Skip to content

A platform for community discussion. Free, open, simple.

FIX: Skip full app embed iframes in push notification click handler (#39465)

Rafael dos Santos Silvaf4cbef5e2f71
diff --git a/app/views/static/service-worker.js.erb b/app/views/static/service-worker.js.erb
index db132d8abd4..a1868b739ea 100644
--- a/app/views/static/service-worker.js.erb
+++ b/app/views/static/service-worker.js.erb
@@ -78,7 +78,13 @@ self.addEventListener('notificationclick', function(event) {
// focuses if it is
event.waitUntil(
clients.matchAll({ type: "window" }).then(function (clientList) {
- var reusedClientWindow = clientList.some(function (client) {
+ // Skip nested frames (e.g. full-app embed iframes) — we want to
+ // focus/open a standalone Discourse window, not navigate an embed.
+ var topLevelClients = clientList.filter(function (client) {
+ return client.frameType !== "nested";
+ });
+
+ var reusedClientWindow = topLevelClients.some(function (client) {
if (client.url === baseUrl + url && "focus" in client) {
client.focus();
return true;