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
2 people authored and Jocs committed Mar 23, 2024
1 parent b695b2e commit adff6fb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 adff6fb

Please sign in to comment.