Skip to content

Commit 017e89f

Browse files
committed
fix(core): should be bound to the correct object (#8121)
<img width="795" alt="Screenshot 2024-09-05 at 18 05 35" src="https://github.com/user-attachments/assets/46f277e9-9be6-4f71-b765-fc442a3a9c64">
1 parent d3f50a2 commit 017e89f

File tree

1 file changed

+20
-20
lines changed
  • packages/frontend/core/src/modules/editor/entities

1 file changed

+20
-20
lines changed

packages/frontend/core/src/modules/editor/entities/editor.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -181,20 +181,20 @@ export class Editor extends Entity {
181181
>('rich-text');
182182
title?.inlineEditor.focusEnd();
183183
}
184-
unsubs.push(
185-
focusAt$
186-
.distinctUntilChanged(
187-
(a, b) => a?.id === b?.id && a?.refreshKey === b?.refreshKey
188-
)
189-
.subscribe(params => {
190-
if (params?.id) {
191-
const std = editorContainer.host?.std;
192-
if (std) {
193-
scrollAnchoring(std, this.mode$.value, params.id);
194-
}
184+
185+
const subscription = focusAt$
186+
.distinctUntilChanged(
187+
(a, b) => a?.id === b?.id && a?.refreshKey === b?.refreshKey
188+
)
189+
.subscribe(params => {
190+
if (params?.id) {
191+
const std = editorContainer.host?.std;
192+
if (std) {
193+
scrollAnchoring(std, this.mode$.value, params.id);
195194
}
196-
}).unsubscribe
197-
);
195+
}
196+
});
197+
unsubs.push(subscription.unsubscribe.bind(subscription));
198198

199199
const edgelessPage = editorContainer.host?.querySelector(
200200
'affine-edgeless-root'
@@ -205,13 +205,13 @@ export class Editor extends Entity {
205205
this.isPresenting$.next(
206206
edgelessPage.edgelessTool.type === 'frameNavigator'
207207
);
208-
unsubs.push(
209-
edgelessPage.slots.edgelessToolUpdated.on(() => {
210-
this.isPresenting$.next(
211-
edgelessPage.edgelessTool.type === 'frameNavigator'
212-
);
213-
}).dispose
214-
);
208+
209+
const disposable = edgelessPage.slots.edgelessToolUpdated.on(() => {
210+
this.isPresenting$.next(
211+
edgelessPage.edgelessTool.type === 'frameNavigator'
212+
);
213+
});
214+
unsubs.push(disposable.dispose.bind(disposable));
215215
}
216216

217217
return () => {

0 commit comments

Comments
 (0)