Skip to content

Commit 1d7ca6f

Browse files
fix: Table handles hide when selection is active (#1111)
* Made table handles hide when selection is active * Changed logic
1 parent d198f89 commit 1d7ca6f

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

packages/core/src/extensions/TableHandles/TableHandlesPlugin.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ export class TableHandlesView<
107107

108108
public menuFrozen = false;
109109

110+
public mouseState: "up" | "down" | "selecting" = "up";
111+
110112
public prevWasEditable: boolean | null = null;
111113

112114
constructor(
@@ -127,6 +129,8 @@ export class TableHandlesView<
127129
};
128130

129131
pmView.dom.addEventListener("mousemove", this.mouseMoveHandler);
132+
pmView.dom.addEventListener("mousedown", this.viewMousedownHandler);
133+
pmView.dom.addEventListener("mouseup", this.viewMouseupHandler);
130134

131135
pmView.root.addEventListener(
132136
"dragover",
@@ -140,11 +144,33 @@ export class TableHandlesView<
140144
pmView.root.addEventListener("scroll", this.scrollHandler, true);
141145
}
142146

147+
viewMousedownHandler = () => {
148+
this.mouseState = "down";
149+
};
150+
151+
viewMouseupHandler = (event: MouseEvent) => {
152+
this.mouseState = "up";
153+
this.mouseMoveHandler(event);
154+
};
155+
143156
mouseMoveHandler = (event: MouseEvent) => {
144157
if (this.menuFrozen) {
145158
return;
146159
}
147160

161+
if (this.mouseState === "down") {
162+
this.mouseState = "selecting";
163+
164+
if (this.state?.show) {
165+
this.state.show = false;
166+
this.emitUpdate();
167+
}
168+
}
169+
170+
if (this.mouseState === "selecting") {
171+
return;
172+
}
173+
148174
const target = domCellAround(event.target as HTMLElement);
149175

150176
if (!target || !this.editor.isEditable) {

0 commit comments

Comments
 (0)