Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Table handles hide when selection is active #1111

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions packages/core/src/extensions/TableHandles/TableHandlesPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export class TableHandlesView<
};

pmView.dom.addEventListener("mousemove", this.mouseMoveHandler);
pmView.dom.addEventListener("mouseup", this.mouseUpHandler);

pmView.root.addEventListener(
"dragover",
Expand All @@ -145,6 +146,16 @@ export class TableHandlesView<
return;
}

// Prevents table handles from showing while a selection is active.
if (!this.pmView.state.selection.empty) {
matthewlipski marked this conversation as resolved.
Show resolved Hide resolved
if (this.state?.show) {
this.state.show = false;
this.emitUpdate();
}

return;
}

const target = domCellAround(event.target as HTMLElement);

if (!target || !this.editor.isEditable) {
Expand Down Expand Up @@ -231,6 +242,11 @@ export class TableHandlesView<
return false;
};

mouseUpHandler = (event: MouseEvent) => {
// Have to wait for changes from view to propagate to state.
setTimeout(() => this.mouseMoveHandler(event), 10);
matthewlipski marked this conversation as resolved.
Show resolved Hide resolved
};

dragOverHandler = (event: DragEvent) => {
if (this.state?.draggingState === undefined) {
return;
Expand Down
Loading