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
This commit is contained in:
Hazem Krimi
2025-05-02 15:53:54 +01:00
committed by GitHub
parent cd6ea60fa1
commit a16bf555c0

View File

@@ -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 () {