Skip to content
Closed
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
17 changes: 9 additions & 8 deletions frontend/src/components/widgets/inputs/NumberInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,14 @@
if (alreadyActedGuard) return;
alreadyActedGuard = true;
isDragging = true;
beginDrag(e);

// We need to request pointer lock as immediately as possible for Safari compatibility
const target = e.target || undefined;
if (!(target instanceof HTMLElement)) return;

target.requestPointerLock();

beginDrag();
removeEventListener("pointermove", onMove);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this now leaking the pointermove event now that we are sometimes early returning before this line? Seems like the target.requestPointerLock(); and beginDrag(); lines should be inside the if statement instead of the early return in its inverse.

};
// If it's a mouseup, we'll begin editing the text field.
Expand All @@ -340,13 +347,7 @@
addEventListener("pointerup", onUp);
}

function beginDrag(e: PointerEvent) {
// Get the click target
const target = e.target || undefined;
if (!(target instanceof HTMLElement)) return;

// Enter dragging state
target.requestPointerLock();
function beginDrag() {
initialValueBeforeDragging = value;
cumulativeDragDelta = 0;

Expand Down
Loading