Guard drag handle from re-showing mid-drag, use semantic button

This commit is contained in:
Tom Moor committed 2026-10-09 22:13:32 -04:00
1 parent 1ef8f35787
commit 990c0268e4
1 file changed
+13 -1
+13 -1
View File
@@ -172,6 +172,12 @@ export default class DragHandle extends Extension {
};
const onScroll = () => {
// While a drag is in progress the handle is intentionally hidden;
// don't let a scroll (trackpad / auto-scroll) reposition and
// re-show it mid-drag.
if (pluginKey.getState(view.state)) {
return;
}
if (target?.element.isConnected) {
show(target);
} else {
@@ -281,11 +287,17 @@ export default class DragHandle extends Extension {
}
function createHandle(): HTMLElement {
const handle = document.createElement("div");
const handle = document.createElement("button");
handle.type = "button";
handle.className = HANDLE_CLASS;
handle.draggable = true;
handle.contentEditable = "false";
handle.setAttribute("aria-label", "Drag to reorder");
// Reset the native button chrome so only the icon background shows.
handle.style.appearance = "none";
handle.style.border = "0";
handle.style.padding = "0";
handle.style.backgroundColor = "transparent";
handle.style.position = "fixed";
handle.style.width = `${HANDLE_SIZE}px`;
handle.style.height = `${HANDLE_SIZE}px`;