From 5e54caf04c3cb5dd3794c560aec86830b2ec5a87 Mon Sep 17 00:00:00 2001 From: Eva Date: Mon, 6 May 2024 19:39:56 +0200 Subject: [PATCH] client/views: fix middle click prevention on buttons for modern browsers Browsers no longer fire the primary 'click' event for middle clicks. Old way kept for compatibility as it doesn't hurt anything. All browsers that support auxclick also have standardized MouseEvent.button values. --- client/js/util/views.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/js/util/views.js b/client/js/util/views.js index f6280a1c..3ea3a336 100644 --- a/client/js/util/views.js +++ b/client/js/util/views.js @@ -571,6 +571,11 @@ document.addEventListener("click", (e) => { e.preventDefault(); } }); +document.addEventListener("auxclick", (e) => { + if (e.target.getAttribute("href") === "" && e.button === 1) { + e.preventDefault(); + } +}); module.exports = { htmlToDom: htmlToDom,