Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

Trigger ESC shortcut on instance detail only when in the instance detail page has focus

Tianzhou Chen1c7a611fcf2f
diff --git a/frontend/src/views/InstanceDetail.vue b/frontend/src/views/InstanceDetail.vue
index 5023e18bd5..b3ff8bb66c 100644
--- a/frontend/src/views/InstanceDetail.vue
+++ b/frontend/src/views/InstanceDetail.vue
@@ -305,7 +305,7 @@ input[type="number"] {
</template>
<script lang="ts">
-import { computed, onMounted, reactive } from "vue";
+import { computed, onMounted, onUnmounted, reactive } from "vue";
import { useStore } from "vuex";
import { useRouter } from "vue-router";
import isEqual from "lodash-es/isEqual";
@@ -355,12 +355,22 @@ export default {
showPassword: false,
});
+ const escHandler = (e: KeyboardEvent) => {
+ if (
+ e.code == "Escape" &&
+ !state.showDeleteModal &&
+ !state.showCancelModal
+ ) {
+ cancel();
+ }
+ };
+
onMounted(() => {
- document.addEventListener("keydown", (e) => {
- if (e.code == "Escape") {
- goBack();
- }
- });
+ document.addEventListener("keydown", escHandler);
+ });
+
+ onUnmounted(() => {
+ document.removeEventListener("keydown", escHandler);
});
const assignInstance = (instance: Instance | NewInstance) => {