From 4c33d24a7b856488df73407ae418c5df9701c27d Mon Sep 17 00:00:00 2001 From: Red Adaya Date: Tue, 12 Mar 2024 09:31:35 +0800 Subject: [PATCH] close modals on ECS --- src/app/common/modals/alert.tsx | 2 +- src/models/bookmarks.ts | 2 +- src/models/clientsettingsview.ts | 10 ++++++++++ src/models/connectionsview.ts | 10 ++++++++++ src/models/historyview.ts | 2 +- src/models/modals.ts | 3 ++- src/models/model.ts | 11 +++++++---- 7 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/app/common/modals/alert.tsx b/src/app/common/modals/alert.tsx index f128f26d8..714869aec 100644 --- a/src/app/common/modals/alert.tsx +++ b/src/app/common/modals/alert.tsx @@ -44,7 +44,7 @@ class AlertModal extends React.Component<{}, {}> { {message?.message} - + void) { mobx.action(() => { this.store.pop(); })(); + callback && callback(); } } diff --git a/src/models/model.ts b/src/models/model.ts index 233049a83..423ad80aa 100644 --- a/src/models/model.ts +++ b/src/models/model.ts @@ -457,7 +457,7 @@ class Model { if (this.alertMessage.get() != null) { if (checkKeyPressed(waveEvent, "Escape")) { e.preventDefault(); - this.cancelAlert(); + this.modalsModel.popModal(() => this.cancelAlert()); return; } if (checkKeyPressed(waveEvent, "Enter")) { @@ -467,6 +467,10 @@ class Model { } return; } + if (checkKeyPressed(waveEvent, "Escape") && this.modalsModel.store.length > 0) { + this.modalsModel.popModal(); + return; + } if (this.activeMainView.get() == "bookmarks") { this.bookmarksModel.handleDocKeyDown(e); return; @@ -476,14 +480,13 @@ class Model { return; } if (this.activeMainView.get() == "connections") { - this.historyViewModel.handleDocKeyDown(e); + this.connectionViewModel.handleDocKeyDown(e); return; } if (this.activeMainView.get() == "clientsettings") { - this.historyViewModel.handleDocKeyDown(e); + this.clientSettingsViewModel.handleDocKeyDown(e); return; } - if (checkKeyPressed(waveEvent, "Escape")) { e.preventDefault(); if (this.activeMainView.get() == "webshare") {