Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove menu bar on editor destroy. #16329

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ function destroyEditor() {
editor.destroy()
.then( () => {
editor.ui.view.toolbar.element.remove();
editor.ui.view.menuBarView.element.remove();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider changing the order of operations in the destroyEditor function.

- editor.destroy()
-   .then( () => {
-     editor.ui.view.toolbar.element.remove();
-     editor.ui.view.menuBarView.element.remove();
-     window.editor = editor = null;
-     window.editables = null;
-     console.log( 'Editor was destroyed' );
-   } );
+ editor.ui.view.toolbar.element.remove();
+ editor.ui.view.menuBarView.element.remove();
+ editor.destroy()
+   .then( () => {
+     window.editor = editor = null;
+     window.editables = null;
+     console.log( 'Editor was destroyed' );
+   } );

The elements should be removed before calling editor.destroy() to ensure that all UI components are cleaned up before the editor instance is terminated. This helps prevent any potential issues that might arise if the editor's destruction process interferes with the removal of UI elements.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
editor.ui.view.menuBarView.element.remove();
editor.ui.view.toolbar.element.remove();
editor.ui.view.menuBarView.element.remove();
editor.destroy()
.then( () => {
window.editor = editor = null;
window.editables = null;
console.log( 'Editor was destroyed' );
} );


window.editor = editor = null;
window.editables = null;
Expand Down