feat: Improve cursor handling during drag operations for better user experience

This commit is contained in:
Will Miao
2025-08-22 15:36:27 +08:00
parent 1bf9326604
commit 383b4de539
3 changed files with 12 additions and 3 deletions

View File

@@ -291,7 +291,6 @@ export function addLorasWidget(node, name, opts, callback) {
whiteSpace: "nowrap",
color: active ? "rgba(226, 232, 240, 0.9)" : "rgba(226, 232, 240, 0.6)",
fontSize: "13px",
cursor: "pointer",
userSelect: "none",
WebkitUserSelect: "none",
MozUserSelect: "none",

View File

@@ -115,6 +115,10 @@ export function createDragHandle() {
handle.onmousedown = () => {
handle.style.cursor = "grabbing";
};
handle.onmouseup = () => {
handle.style.cursor = "grab";
};
return handle;
}

View File

@@ -304,6 +304,9 @@ export function initReorderDrag(dragHandle, loraName, widget, renderFunction) {
});
document.addEventListener('mouseup', (e) => {
// Always reset cursor regardless of isDragging state
document.body.style.cursor = '';
if (!isDragging || !draggedElement) return;
const targetIndex = getDropTargetIndex(container, e.clientY);
@@ -356,10 +359,13 @@ export function initReorderDrag(dragHandle, loraName, widget, renderFunction) {
dropIndicator = null;
}
// Reset cursor
document.body.style.cursor = '';
container = null;
});
// Also reset cursor when mouse leaves the document
document.addEventListener('mouseleave', () => {
document.body.style.cursor = '';
});
}
// Function to handle keyboard navigation