From f9e0765ed9c2dbcd95757de240f3f673cf717449 Mon Sep 17 00:00:00 2001 From: Paulo Andre Azevedo Quirino Date: Wed, 9 Oct 2024 15:55:08 +0100 Subject: [PATCH] - FP-2770: Scene closing button not working when with changes * --- CHANGELOG.md | 4 ++++ src/plugins/DocManager/DocManager.js | 5 ++++- src/plugins/views/Tabs/hooks/useTabLayout.js | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b40b2e11..0e750dbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# TBD + +- [FP-2770](https://movai.atlassian.net/browse/FP-2770) Scene closing button not working when with changes * + # 1.2.9 - [FP-2926](https://movai.atlassian.net/browse/FP-2926): Clear console and app errors diff --git a/src/plugins/DocManager/DocManager.js b/src/plugins/DocManager/DocManager.js index 7f3e0496..78b01040 100644 --- a/src/plugins/DocManager/DocManager.js +++ b/src/plugins/DocManager/DocManager.js @@ -248,7 +248,10 @@ class DocManager extends IDEPlugin { return this.call(PLUGINS.DIALOG.NAME, PLUGINS.DIALOG.CALL.NEW_DOC, { scope, placeholder: name, - onSubmit: newName => this.doSave(modelKey, callback, newName, opts), + onSubmit: newName => { + this.doSave(modelKey, callback, newName, opts); + this.discardDocChanges({ scope, name: newName }); + }, onClose: () => this.saveStack.delete(`${name}_${scope}`) }); } diff --git a/src/plugins/views/Tabs/hooks/useTabLayout.js b/src/plugins/views/Tabs/hooks/useTabLayout.js index 448f25e4..bd332cb1 100644 --- a/src/plugins/views/Tabs/hooks/useTabLayout.js +++ b/src/plugins/views/Tabs/hooks/useTabLayout.js @@ -340,7 +340,7 @@ const useTabLayout = (props, dockRef) => { */ const _onLayoutRemoveTab = useCallback( (newLayout, tabId, forceClose) => { - const { name, scope, isNew, isDirty } = tabsByIdRef.current.get(tabId); + const { name, scope, isNew, isDirty } = tabsByIdRef.current?.get(tabId) ?? {}; if (isDirty && !forceClose) { const document = { id: tabId, name, scope, isNew };