From a16bf555c0124e84d7381e7677c4e78fe22ff6b8 Mon Sep 17 00:00:00 2001 From: Hazem Krimi Date: Fri, 2 May 2025 15:53:54 +0100 Subject: [PATCH] feat(gui): close a modal when pressing ESC after switching modal tabs (fixes #9489) (#10092) ### Purpose As stated in #9489 after clicking on a tab link to switch tabs in a modal you can no longer close the modal through clicking the ESC key unless you click anywhere on the modal to focus on it again. ### Testing - Click on a modal that has tabs like "Settings" or "Add Folder" and switch tabs then click on ESC. - Check if clicking outside of a modal in the backdrop should still close the modal. ### Demo https://github.com/user-attachments/assets/a010db9a-72f7-4160-a7db-ddfebffb4834 --- gui/default/syncthing/core/modalDirective.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gui/default/syncthing/core/modalDirective.js b/gui/default/syncthing/core/modalDirective.js index cc8ee4a95..03102dbe2 100644 --- a/gui/default/syncthing/core/modalDirective.js +++ b/gui/default/syncthing/core/modalDirective.js @@ -16,6 +16,14 @@ angular.module('syncthing.core') }, link: function (scope, element, attrs) { + $(element).on('click', function (event) { + const closestTabAnchor = event.target.closest('a[data-toggle="tab"]'); + + if (closestTabAnchor && closestTabAnchor.href.includes('#')) { + event.preventDefault(); + } + }); + // before modal show animation $(element).on('show.bs.modal', function () {