From 8ba77de57148d6edb07c9ffb7b5f564d7cf4e50d Mon Sep 17 00:00:00 2001 From: Noah Date: Fri, 30 Oct 2026 05:59:28 +0100 Subject: [PATCH] [chuchi] don't intercept handled clicks, other buttons and other targets A click that another handler already prevented, a click with another button than the main one, and links into another window or frame (_top, _parent, a named target, not only _blank) were opened by the router. Found in zipp's studio, which had to stop such clicks itself. Co-Authored-By: Claude Opus 5.5 --- chuchi/src/routing/Router.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/chuchi/src/routing/Router.ts b/chuchi/src/routing/Router.ts index ad2ae61..d5ace41 100644 --- a/chuchi/src/routing/Router.ts +++ b/chuchi/src/routing/Router.ts @@ -410,10 +410,14 @@ function shouldInterceptClick( e: MouseEvent, link: HTMLAnchorElement | null, ): boolean { + // another handler took care of it, or not the main button + if (e.defaultPrevented || e.button !== 0) return false; const openInNewTab = e.metaKey || e.ctrlKey || e.shiftKey; const saveLink = e.altKey; if (!link || !link.href || openInNewTab || saveLink) return false; - if (link.target.toLowerCase() === '_blank') return false; + // another window or frame: _blank, _top, _parent or a named one + const target = link.target.toLowerCase(); + if (target && target !== '_self') return false; if (link.hasAttribute('download')) return false; if (!link.href.startsWith('http')) return false;