Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix(editor): should not update table selection after table is destroyed (#9665)

zzj372080f8944188c7
diff --git a/blocksuite/affine/data-view/src/core/group-by/renderer/select-group.ts b/blocksuite/affine/data-view/src/core/group-by/renderer/select-group.ts
index ad36f6f483..b4200045d0 100644
--- a/blocksuite/affine/data-view/src/core/group-by/renderer/select-group.ts
+++ b/blocksuite/affine/data-view/src/core/group-by/renderer/select-group.ts
@@ -78,7 +78,7 @@ export class SelectGroupView extends BaseGroup<
};
get tag() {
- return this.data.options.find(v => v.id === this.value);
+ return this.data.options?.find(v => v.id === this.value);
}
protected override render(): unknown {
diff --git a/blocksuite/affine/data-view/src/view-presets/table/pc/controller/selection.ts b/blocksuite/affine/data-view/src/view-presets/table/pc/controller/selection.ts
index 484b01fcd0..f87c69a384 100644
--- a/blocksuite/affine/data-view/src/view-presets/table/pc/controller/selection.ts
+++ b/blocksuite/affine/data-view/src/view-presets/table/pc/controller/selection.ts
@@ -1017,6 +1017,9 @@ export class SelectionElement extends WithDisposable(ShadowlessElement) {
this.disposables.add(
effect(() => {
this.startUpdate(this.selection$.value);
+ return () => {
+ this.cancelSelectionUpdate();
+ };
})
);
}
@@ -1033,11 +1036,15 @@ export class SelectionElement extends WithDisposable(ShadowlessElement) {
`;
}
- startUpdate(selection?: TableViewSelection) {
+ cancelSelectionUpdate() {
if (this.preTask) {
cancelAnimationFrame(this.preTask);
this.preTask = 0;
}
+ }
+
+ startUpdate(selection?: TableViewSelection) {
+ this.cancelSelectionUpdate();
if (
selection?.selectionType === 'area' &&
!this.controller.host.props.view.readonly$.value