diff --git a/CHANGELOG.md b/CHANGELOG.md index 270b32bb..86e0ce9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # 1.0.0 --installs on--> 2.4 IDE-EE / 3.1 IDE-CE +- [FP-2527 - Preventing the reload of a new doc when it's closed](https://movai.atlassian.net/browse/FP-2527) - [FP-2216 - IDE- black screen after changing resolution](https://movai.atlassian.net/browse/FP-2216) - [FP-2542 - Removed code that prevented flow validations from running](https://movai.atlassian.net/browse/FP-2542) - [FP-2540 - Duplicated code on the new merge request](https://movai.atlassian.net/browse/FP-2540) diff --git a/src/plugins/DocManager/DocManager.js b/src/plugins/DocManager/DocManager.js index 6afccb93..9ae57ebc 100644 --- a/src/plugins/DocManager/DocManager.js +++ b/src/plugins/DocManager/DocManager.js @@ -217,7 +217,7 @@ class DocManager extends IDEPlugin { scope, onSubmit: async action => { switch (action) { - case SAVE_OUTDATED_DOC_ACTIONS.UPDATE_DOC: + case SAVE_OUTDATED_DOC_ACTIONS.UPDATE_DOC: { this.discardDocChanges(modelKey); const updatedDoc = await this.read(modelKey); @@ -229,6 +229,7 @@ class DocManager extends IDEPlugin { this.saveStack.delete(`${name}_${scope}`); break; + } case SAVE_OUTDATED_DOC_ACTIONS.OVERWRITE_DOC: this.doSave(modelKey, callback, undefined, opts); break; @@ -289,7 +290,7 @@ class DocManager extends IDEPlugin { }); } - callback && callback(returnMessage); + callback?.(returnMessage); this.saveStack.delete(`${name}_${scope}`); return returnMessage; } @@ -424,7 +425,7 @@ class DocManager extends IDEPlugin { * Remove subscribers * @param {Event} event */ - onUnload = _event => { + onUnload = () => { this.getStores().forEach(store => { const dirtyDocs = store.getDirties(); diff --git a/src/plugins/views/Tabs/hooks/useTabLayout.js b/src/plugins/views/Tabs/hooks/useTabLayout.js index 1e26a6e1..8ee4c6fa 100644 --- a/src/plugins/views/Tabs/hooks/useTabLayout.js +++ b/src/plugins/views/Tabs/hooks/useTabLayout.js @@ -25,6 +25,7 @@ const useTabLayout = (props, dockRef) => { const workspaceManager = useMemo(() => new Workspace(), []); const activeTabId = useRef(null); const firstLoad = useRef(true); + const preventReloadNewDoc = useRef(false); const tabsById = useRef(new Map()); const [layout, setLayout] = useState({ ...DEFAULT_LAYOUT }); const { addTabToStack, removeTabFromStack, getNextTabFromStack } = @@ -198,8 +199,9 @@ const useTabLayout = (props, dockRef) => { const newLayout = { ...prevLayout }; const box = _getTabContainer(newLayout[location], prevTabId); if (box) { - tabData.id = `${tabData.id.substring(0, tabData.id.lastIndexOf("/"))}/${tabData.name - }`; + tabData.id = `${tabData.id.substring(0, tabData.id.lastIndexOf("/"))}/${ + tabData.name + }`; const tabIndex = box.tabs.findIndex(_el => _el.id === prevTabId); box.tabs[tabIndex] = tabData; box.activeId = tabData.id; @@ -305,6 +307,7 @@ const useTabLayout = (props, dockRef) => { name, scope, onSubmit: action => { + preventReloadNewDoc.current = true; const triggerAction = { // Save changes and close document save: () => _saveDoc(document), @@ -460,7 +463,10 @@ const useTabLayout = (props, dockRef) => { if (!docFactory) return docData; return installTabPlugin(docFactory, docData) .then(viewPlugin => { - const Decorated = withError(() => viewPlugin.render(docFactory.props ?? {}), dependencies); + const Decorated = withError( + () => viewPlugin.render(docFactory.props ?? {}), + dependencies + ); // Create and return tab data const extension = docFactory.store.model.EXTENSION ?? ""; @@ -773,10 +779,14 @@ const useTabLayout = (props, dockRef) => { updateTabId(doc.path.replace(`/${doc.version}`, ""), newTabData); - call(PLUGINS.DOC_MANAGER.NAME, PLUGINS.DOC_MANAGER.CALL.RELOAD_DOC, { - scope, - name - }); + if (!preventReloadNewDoc.current) { + call(PLUGINS.DOC_MANAGER.NAME, PLUGINS.DOC_MANAGER.CALL.RELOAD_DOC, { + scope, + name + }); + } + + preventReloadNewDoc.current = false; } }); // Unsubscribe on unmount