Skip to content

Commit b11cf71

Browse files
committed
fix(editor): add guard to clearSelectedBlock to prevent unnecessary events
1 parent 668c3d9 commit b11cf71

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@craftile/editor": patch
3+
---
4+
5+
fix(editor): add guard to clearSelectedBlock to prevent unnecessary events
6+
7+
Add early return in `clearSelectedBlock()` when no block is selected, preventing unnecessary event emissions and state updates.

packages/editor/src/managers/ui.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ export class UIManager {
7676
}
7777

7878
clearSelectedBlock(): void {
79+
if (!this.state.selectedBlockId) {
80+
return;
81+
}
82+
7983
this.state.selectedBlockId = null;
8084
this.events.emit('ui:block:clear-selection', { blockId: null });
8185
}

0 commit comments

Comments
 (0)