fix(editor): clear remote selection when editor is deactive (#11450)
Closes: BS-3022
This commit is contained in:
@@ -323,6 +323,14 @@ export class AffineDocRemoteSelectionWidget extends WidgetComponent {
|
|||||||
this._updateSelections(selections);
|
this._updateSelections(selections);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.disposables.add(
|
||||||
|
this.std.event.active$.subscribe(value => {
|
||||||
|
if (!value) {
|
||||||
|
this.std.selection.clearRemote();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
override render() {
|
override render() {
|
||||||
|
|||||||
@@ -162,6 +162,13 @@ export class StoreSelectionExtension extends StoreExtension {
|
|||||||
this.set([...current, ...selections]);
|
this.set([...current, ...selections]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This method is used to clear **current editor's remote selections**
|
||||||
|
// When the editor is not active, the remote selections should be cleared
|
||||||
|
// So other editors won't see the remote selections from this editor
|
||||||
|
clearRemote() {
|
||||||
|
this.store.awarenessStore.setLocalSelection(this._id, []);
|
||||||
|
}
|
||||||
|
|
||||||
update(fn: (currentSelections: BaseSelection[]) => BaseSelection[]) {
|
update(fn: (currentSelections: BaseSelection[]) => BaseSelection[]) {
|
||||||
const selections = fn(this.value);
|
const selections = fn(this.value);
|
||||||
this.set(selections);
|
this.set(selections);
|
||||||
|
|||||||
Reference in New Issue
Block a user