From e15189b20c9cb260fbc8821b2ee606c253d68805 Mon Sep 17 00:00:00 2001 From: Gittenburg Date: Thu, 16 Jul 2020 10:46:32 +0200 Subject: [PATCH] click_handlers: Don't focus links on middle / right click. --- static/js/click_handlers.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/static/js/click_handlers.js b/static/js/click_handlers.js index 55d0f2efcc..2995c8c58c 100644 --- a/static/js/click_handlers.js +++ b/static/js/click_handlers.js @@ -739,7 +739,17 @@ exports.initialize = function () { // Chrome focuses an element when dragging it which can be confusing when // users involuntarily drag something and we show them the focus outline. - $('body').on('dragstart', (e) => e.target.blur()); + $('body').on('dragstart', 'a', (e) => e.target.blur()); + + // Don't focus links on middle click. + $('body').on('mouseup', 'a', (e) => { + if (e.which === 2) { // middle click + e.target.blur(); + } + }); + + // Don't focus links on context menu. + $('body').on('contextmenu', 'a', (e) => e.target.blur()); (function () { const map = {