Skip to content

Commit

Permalink
fix(ui): cleanup DOMs when dispose (#1663)
Browse files Browse the repository at this point in the history
* fix: cleanup DOMs on dispose

* refactor(sheet-ui): simplified dispose

Co-authored-by: Wenzhao Hu <wzhudev@gmail.com>

---------

Co-authored-by: Wenzhao Hu <wzhudev@gmail.com>
  • Loading branch information
hexf00 and wzhudev committed Mar 22, 2024
1 parent ff686e6 commit b81ba1a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
Expand Up @@ -116,6 +116,8 @@ export class SheetClipboardService extends Disposable implements ISheetClipboard
});
this._usmToHtml = new USMToHtmlService();
this._copyContentCache = new CopyContentCache();

this.disposeWithMe(this._htmlToUSM);
}

copyContentCache(): CopyContentCache {
Expand Down
Expand Up @@ -383,6 +383,10 @@ export class HtmlToUSMService {
}
}
}

dispose() {
document.body.removeChild(this.htmlElement);
}
}

/**
Expand Down
3 changes: 3 additions & 0 deletions packages/ui/src/views/App.tsx
Expand Up @@ -83,6 +83,9 @@ export function App(props: IUniverAppProps) {
return () => {
// batch unsubscribe
subscriptions.forEach((subscription) => subscription.unsubscribe());

// cleanup
document.body.removeChild(portalContainer);
};
}, [localeService, messageService, mountContainer, portalContainer, themeService.currentTheme$]);

Expand Down

0 comments on commit b81ba1a

Please sign in to comment.