mirror of https://github.com/laurent22/joplin.git
Desktop: Fix crash when closing a secondary window with the Rich Text Editor open (#11737)
parent
67d1dd36be
commit
f90e642f43
|
@ -1387,7 +1387,17 @@ const TinyMCE = (props: NoteBodyEditorProps, ref: any) => {
|
|||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (editorRef.current) editorRef.current.remove();
|
||||
if (!editorRef.current) return;
|
||||
|
||||
const ownerDocument = editorRef.current.getContainer().ownerDocument;
|
||||
const parentWindow = ownerDocument.defaultView;
|
||||
|
||||
// Calling .remove after the parent window is closed throws an Error
|
||||
// related to DOM API access. Since closing the window also removes the editor,
|
||||
// it shouldn't be necessary to call .remove in this case:
|
||||
if (parentWindow) {
|
||||
editorRef.current.remove();
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
|
||||
|
|
Loading…
Reference in New Issue