Skip to content

Commit 5102192

Browse files
Fixed side menu not appearing after clicking add block button (#395)
1 parent 1930313 commit 5102192

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

packages/core/src/extensions/SideMenu/SideMenuPlugin.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ export class SideMenuView<BSchema extends BlockSchema> implements PluginView {
265265
// Makes menu scroll with the page.
266266
document.addEventListener("scroll", this.onScroll);
267267

268+
// Unfreezes the menu whenever the user clicks anywhere.
269+
document.body.addEventListener("mousedown", this.onMouseDown, true);
268270
// Hides and unfreezes the menu whenever the user presses a key.
269271
document.body.addEventListener("keydown", this.onKeyDown, true);
270272
}
@@ -347,6 +349,14 @@ export class SideMenuView<BSchema extends BlockSchema> implements PluginView {
347349
this.menuFrozen = false;
348350
};
349351

352+
onMouseDown = (_event: MouseEvent) => {
353+
if (this.sideMenuState && !this.sideMenuState.show) {
354+
this.sideMenuState.show = true;
355+
this.updateSideMenu(this.sideMenuState);
356+
}
357+
this.menuFrozen = false;
358+
};
359+
350360
onMouseMove = (event: MouseEvent) => {
351361
if (this.menuFrozen) {
352362
return;
@@ -479,6 +489,7 @@ export class SideMenuView<BSchema extends BlockSchema> implements PluginView {
479489
this.pmView.dom.removeEventListener("dragstart", this.onDragStart);
480490
document.body.removeEventListener("drop", this.onDrop, true);
481491
document.removeEventListener("scroll", this.onScroll);
492+
document.body.removeEventListener("mousedown", this.onMouseDown, true);
482493
document.body.removeEventListener("keydown", this.onKeyDown, true);
483494
}
484495

0 commit comments

Comments
 (0)