From ae6ba0d9e0e7e5e57fa13a40558ff96f18e898f3 Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Tue, 7 Oct 2025 20:50:59 -0400 Subject: [PATCH] Prevent VideoCard clicks from navigating --- js/ui/components/VideoCard.js | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/js/ui/components/VideoCard.js b/js/ui/components/VideoCard.js index b0e9f26d..8c08f6a6 100644 --- a/js/ui/components/VideoCard.js +++ b/js/ui/components/VideoCard.js @@ -983,12 +983,35 @@ export class VideoCard { this.ensureGlobalMoreMenuHandlers(); } + const MouseEventCtor = this.window?.MouseEvent || globalThis.MouseEvent; + [this.anchorEl, this.titleEl].forEach((el) => { if (!el) return; el.addEventListener("click", (event) => { - if (this.callbacks.onPlay) { - this.callbacks.onPlay({ event, video: this.video, card: this }); + if (!this.callbacks.onPlay) { + return; } + + const isMouseEvent = + typeof MouseEventCtor !== "undefined" && event instanceof MouseEventCtor; + if (isMouseEvent) { + const isPrimaryClick = + typeof event.button !== "number" || event.button === 0; + const hasModifier = + event.ctrlKey || event.metaKey || event.shiftKey || event.altKey; + if (!isPrimaryClick || hasModifier) { + return; + } + } + + if (typeof event.preventDefault === "function") { + event.preventDefault(); + } + if (typeof event.stopPropagation === "function") { + event.stopPropagation(); + } + + this.callbacks.onPlay({ event, video: this.video, card: this }); }); });