Skip to content

Fix bug in Safari where number input field click-and-drag can't be released #2876

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

Merged
merged 5 commits into from
Jul 15, 2025
Merged
Changes from all commits
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 @@ -315,6 +315,13 @@
// Don't drag the text value from is input element
e.preventDefault();

// Get the event target and set the requestPointerLock immediately
// Safari seems to require requestPointerLock() to be called directly inside the pointerdown handler instead of later in beginDrag().
const target = e.target || undefined;
if (!(target instanceof HTMLElement)) return;

target.requestPointerLock();

// Now we need to wait and see if the user follows this up with a mousemove or mouseup.

// For some reason, both events can get fired before their event listeners are removed, so we need to guard against both running.
Expand All @@ -325,7 +332,7 @@
if (alreadyActedGuard) return;
alreadyActedGuard = true;
isDragging = true;
beginDrag(e);
beginDrag();
removeEventListener("pointermove", onMove);
};
// 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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy