Skip to content

Commit 351d5ca

Browse files
fix: Minor drag & drop changes (#1891)
1 parent 18bd907 commit 351d5ca

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

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

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -242,21 +242,11 @@ export class SideMenuView<
242242

243243
this.hoveredBlock = block.node;
244244

245-
// Gets the block's content node, which lets to ignore child blocks when determining the block menu's position.
246-
// TODO: needed?
247-
const blockContent = block.node.firstChild as HTMLElement;
248-
249-
if (!blockContent) {
250-
return;
251-
}
252-
253-
// TODO: needed?
254-
255245
// Shows or updates elements.
256246
if (this.editor.isEditable) {
257-
const blockContentBoundingBox = blockContent.getBoundingClientRect();
247+
const blockContentBoundingBox = block.node.getBoundingClientRect();
258248
const column = block.node.closest("[data-node-type=column]");
259-
this.updateState({
249+
this.state = {
260250
show: true,
261251
referencePos: new DOMRect(
262252
column
@@ -275,7 +265,8 @@ export class SideMenuView<
275265
block: this.editor.getBlock(
276266
this.hoveredBlock!.getAttribute("data-id")!,
277267
)!,
278-
});
268+
};
269+
this.updateState(this.state);
279270
}
280271
};
281272

@@ -435,9 +426,9 @@ export class SideMenuView<
435426
// We need to check if there is text content that is being dragged (select some text & just drag it)
436427
const textContentIsBeingDragged =
437428
!event.dataTransfer?.types.includes("blocknote/html") &&
438-
Boolean(this.pmView.dragging);
429+
!!this.pmView.dragging;
439430
// This is the side menu drag from this plugin
440-
const sideMenuIsBeingDragged = Boolean(this.isDragOrigin);
431+
const sideMenuIsBeingDragged = !!this.isDragOrigin;
441432
// Tells us that the current editor instance has a drag ongoing (either text or side menu)
442433
const isDragOrigin = textContentIsBeingDragged || sideMenuIsBeingDragged;
443434

0 commit comments

Comments
 (0)