From 6b6b7867af4c0e00ea107b673a98398db3ef5e91 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 6 Dec 2023 11:07:38 +0100 Subject: [PATCH] Remove focus from the toggleButton when closing the sidebar with a mouse (issue 17361) --- web/pdf_sidebar.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/web/pdf_sidebar.js b/web/pdf_sidebar.js index 50e319de7..8c3e53bd1 100644 --- a/web/pdf_sidebar.js +++ b/web/pdf_sidebar.js @@ -264,7 +264,7 @@ class PDFSidebar { this.#hideUINotification(); } - close() { + close(evt = null) { if (!this.isOpen) { return; } @@ -276,11 +276,16 @@ class PDFSidebar { this.onToggled(); this.#dispatchEvent(); + + if (evt?.detail > 0) { + // Remove focus from the toggleButton if it's clicked (see issue 17361). + this.toggleButton.blur(); + } } - toggle() { + toggle(evt = null) { if (this.isOpen) { - this.close(); + this.close(evt); } else { this.open(); } @@ -334,8 +339,8 @@ class PDFSidebar { } }); - this.toggleButton.addEventListener("click", () => { - this.toggle(); + this.toggleButton.addEventListener("click", evt => { + this.toggle(evt); }); // Buttons for switching views.