mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 13:23:34 -07:00
WebUI: Close modals in the same order as opening
This commit is contained in:
parent
90966cd538
commit
320925aece
1 changed files with 10 additions and 3 deletions
|
@ -1774,14 +1774,21 @@ window.addEventListener("DOMContentLoaded", (event) => {
|
|||
deleteSelectedTorrentsFN(event.shiftKey);
|
||||
break;
|
||||
|
||||
case "Escape":
|
||||
case "Escape": {
|
||||
if (event.target.isContentEditable)
|
||||
return;
|
||||
event.preventDefault();
|
||||
Object.values(MochaUI.Windows.instances).forEach((modal) => {
|
||||
modal.close();
|
||||
const modalInstances = Object.values(MochaUI.Windows.instances);
|
||||
if (modalInstances.length <= 0)
|
||||
return;
|
||||
// MochaUI.currentModal does not update after a modal is closed
|
||||
// use `timestamp` for sequential closing
|
||||
const latestModal = modalInstances.reduce((prev, curr) => {
|
||||
return (prev.timestamp > curr.timestamp) ? prev : curr;
|
||||
});
|
||||
latestModal.close();
|
||||
break;
|
||||
}
|
||||
|
||||
case "f":
|
||||
case "F":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue