mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 13:25:12 +00:00
fix(editor): memory leak caused by missing unsubscription from autoUpdate (#13205)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved resource cleanup for floating UI elements and popups to prevent potential memory leaks and ensure proper disposal when components are removed or updated. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -160,6 +160,7 @@ export class ChatCopyMore extends WithDisposable(LitElement) {
|
||||
mainAxis: 0,
|
||||
crossAxis: -100,
|
||||
});
|
||||
this.disposables.add(() => this._morePopper?.dispose());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,8 @@ export class EdgelessCopilotWidget extends WidgetComponent<RootBlockModel> {
|
||||
|
||||
private _selectionModelRect!: DOMRect;
|
||||
|
||||
private _autoUpdateCleanup: (() => void) | null = null;
|
||||
|
||||
groups: AIItemGroupConfig[] = [];
|
||||
|
||||
get gfx() {
|
||||
@@ -145,7 +147,8 @@ export class EdgelessCopilotWidget extends WidgetComponent<RootBlockModel> {
|
||||
|
||||
const originMaxHeight = window.getComputedStyle(panel).maxHeight;
|
||||
|
||||
autoUpdate(referenceElement, panel, () => {
|
||||
this._autoUpdateCleanup?.();
|
||||
this._autoUpdateCleanup = autoUpdate(referenceElement, panel, () => {
|
||||
computePosition(referenceElement, panel, {
|
||||
placement: 'bottom-start',
|
||||
middleware: [
|
||||
@@ -267,6 +270,8 @@ export class EdgelessCopilotWidget extends WidgetComponent<RootBlockModel> {
|
||||
this._copilotPanel = null;
|
||||
})
|
||||
);
|
||||
|
||||
this._disposables.add(() => this._autoUpdateCleanup?.());
|
||||
}
|
||||
|
||||
determineInsertionBounds(width = 800, height = 95) {
|
||||
|
||||
Reference in New Issue
Block a user