diff --git a/client/web/src/components/workspace/Panel.vue b/client/web/src/components/workspace/Panel.vue index dc167abf7..5b59705a3 100644 --- a/client/web/src/components/workspace/Panel.vue +++ b/client/web/src/components/workspace/Panel.vue @@ -4,7 +4,7 @@
{{ tabLabel }} - +
@@ -143,6 +143,7 @@ import Minimap from "../panels/Minimap.vue"; import IconButton from "../widgets/buttons/IconButton.vue"; import PopoverButton, { PopoverButtonIcon } from "../widgets/buttons/PopoverButton.vue"; import { MenuDirection } from "../widgets/floating-menus/FloatingMenu.vue"; +import { ResponseType, registerResponseHandler, Response } from "../../response-handler"; const wasm = import("../../../wasm/pkg"); @@ -160,6 +161,17 @@ export default defineComponent({ const { select_document } = await wasm; select_document(tabIndex); }, + async closeTab(tabIndex: number) { + const { close_document } = await wasm; + // eslint-disable-next-line no-alert + const result = window.confirm("Closing this document will permanently discard all work. Continue?"); + if (result) close_document(tabIndex); + }, + }, + mounted() { + registerResponseHandler(ResponseType.PromptCloseConfirmationModal, (_responseData: Response) => { + this.closeTab(this.tabActiveIndex); + }); }, props: { tabMinWidths: { type: Boolean, default: false }, diff --git a/client/web/src/components/workspace/Workspace.vue b/client/web/src/components/workspace/Workspace.vue index 2c966d556..b7f3315e5 100644 --- a/client/web/src/components/workspace/Workspace.vue +++ b/client/web/src/components/workspace/Workspace.vue @@ -46,7 +46,7 @@