From 268e89911a21a23d300d6ff3d16c6ea172b218e1 Mon Sep 17 00:00:00 2001 From: fundon Date: Thu, 16 Jan 2025 09:05:10 +0000 Subject: [PATCH] perf(editor): fix autoUpdate being continuously added when updating selections (#9727) Since `updated` is triggered every time click or update the selection, `autoUpdate` will be continuously added. Case: select text and `Shift+ArrowLeft/ArrowRight` --- .../src/root-block/widgets/format-bar/format-bar.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/blocksuite/blocks/src/root-block/widgets/format-bar/format-bar.ts b/blocksuite/blocks/src/root-block/widgets/format-bar/format-bar.ts index 8d455afa0..8ec0e5c5b 100644 --- a/blocksuite/blocks/src/root-block/widgets/format-bar/format-bar.ts +++ b/blocksuite/blocks/src/root-block/widgets/format-bar/format-bar.ts @@ -567,10 +567,12 @@ export class AffineFormatBarWidget extends WidgetComponent { } override updated() { + if (this._floatDisposables) { + this._floatDisposables.dispose(); + this._floatDisposables = null; + } + if (!this._shouldDisplay()) { - if (this._floatDisposables) { - this._floatDisposables.dispose(); - } return; }