Skip to content

Commit 54bd192

Browse files
authored
fix(YfmTable): fix button display while dragging (#854)
1 parent ea018a1 commit 54bd192

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-ghost.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,15 +212,18 @@ export class YfmTableDnDGhost {
212212
const button = target.closest('.g-button');
213213
if (!button) return null;
214214

215+
const container = button.ownerDocument.createElement('div');
216+
container.classList.add('g-md-yfm-table-dnd-ghost-button');
217+
215218
const rect = button.getBoundingClientRect();
216-
const cloned = button.cloneNode(true) as HTMLElement;
219+
const cloned = container.appendChild(button.cloneNode(true) as HTMLElement);
217220

218221
removeIdAttributes(cloned);
219222
cloned.style.cursor = '';
220-
cloned.classList.add('g-md-yfm-table-dnd-ghost-button');
223+
cloned.style.pointerEvents = 'none';
221224

222225
return {
223-
domElement: cloned,
226+
domElement: container,
224227
shiftX: rect.left - this._x,
225228
shiftY: rect.top - this._y,
226229
};

src/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
}
1212

1313
.yfm.g-md-yfm-table-dnd-ghost,
14-
.g-button.g-md-yfm-table-dnd-ghost-button {
14+
.g-md-yfm-table-dnd-ghost-button {
1515
position: fixed;
1616

1717
cursor: grabbing;
@@ -32,7 +32,7 @@
3232
}
3333
}
3434

35-
.g-button.g-md-yfm-table-dnd-ghost-button {
35+
.g-md-yfm-table-dnd-ghost-button {
3636
--g-button-background-color-hover: var(--g-color-base-background);
3737
--g-button-background-color: var(--g-color-base-background);
3838
--g-button-border-color: var(--g-color-line-brand);

0 commit comments

Comments
 (0)