Skip to content

JS debugging: dragging the increment mode number field sometimes jumps at the start #2807

Open

Description

@Keavon

This seems to probably happen more commonly in Chrome, and it seems to be harder to reproduce in Firefox (I wasn't able to reproduce it in FF in my testing right now, @0HyperCube mentions in the comments below that he has encountered it in FF). See NumberInput.svelte.

When you click and drag a number input field of the increment (not range) style, meaning the kind you can drag infinitely left or right, it will sometimes teleport the value to a wildly different value from the one it started with. This can be reproduced by drawing a rectangle and dragging left and right on its stroke weight parameter in the Properties panel repeatedly in quick, small left and right drags until occasionally it will make a big jump.

I hypothesize this is caused by weirdness in the event ordering and mouse position reporting with the pointer lock API, and it might be related to the widget being broken in Safari: #2038. I recommend logging the values that are being reported by the API and current state every frame to narrow down when the events occur and produce the discrepancy.

At the 4-second mark in this video, we see it jump from 131.3 to 17.3 immediately when the click-and-drag begins:

capture_66_.mp4

Activity

  1. added theissue type on Jun 30, 2025
  2. added
    Help WantedExtra attention is needed
    WebInvolves web programming (TypeScript, Svelte, CSS)
    Paper CutA small UX annoyance we should strive to improve
    on Jun 30, 2025
  3. changed the title [-]JS debugging: dragging the increment mode number field sometimes jumps at the start[/-] [+]Chrome JS debugging: dragging the increment mode number field sometimes jumps at the start[/+] on Jun 30, 2025
  4. changed the title [-]Chrome JS debugging: dragging the increment mode number field sometimes jumps at the start[/-] [+]Chrome-specific JS debugging: dragging the increment mode number field sometimes jumps at the start[/+] on Jun 30, 2025
  5. 0HyperCube commented on Jul 5, 2025

    @0HyperCube
    Contributor

    I also sometimes get this on firefox nightly.

  6. changed the title [-]Chrome-specific JS debugging: dragging the increment mode number field sometimes jumps at the start[/-] [+]JS debugging: dragging the increment mode number field sometimes jumps at the start[/+] on Jul 5, 2025
  7. Demohstens commented on Jul 6, 2025

    @Demohstens

    The issue seems to be an underlying issue with how events report mouse movement: https://issues.chromium.org/issues/40547981

    A possible fix is to add the following in Line 385 (NumberInput.svelte)

    if (Math.abs(e.movementX) > 200) {
        // Ignores large jumps in the movementX value caused by a bug in how Inputs are reported.
    	return;
    }

    200 is a magic number based on some debugging that reported numbers in the high hundreds. This also still allowed for smooth-feeling input at higher DPIs.

  8. Keavon commented on Aug 19, 2025

    @Keavon
    MemberAuthor

    A possible workaround: don't use Pointer Lock while dragging on-screen within the web page area, but switch to Pointer Lock when nearing the edge of the screen (screenX). Just hide the cursor by setting the hide-cursor class on the body element during small drags, but we have to be careful to ensure that works when it also goes outside the browser window (this seems to occur automatically while using a drawing tool and dragging with its cursor showing, initially from within the viewport then extending outside the browser).

    This approach won't work in Safari because it incorrectly implements an old version of the Pointer Lock spec, and as such, it wrongly requires an engagement gesture (which isn't a concept in the modern version of the API that FF and Chrome both implement) to be the originating event, so that includes mousedown but not mousemove. But we already can't achieve this in Safari because we have to wait after mousedown for the first frame of mousemove to know that the user is dragging not clicking on the input field, which is why we're unable to use Pointer Lock on Safari (in addition to the fact that Safari displays its notification at the top of the page by resizing and shifting down the entire page contents which is unacceptably jarring).

  9. Anurag-S1ngh commented on Oct 21, 2026

    @Anurag-S1ngh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good First IssueGood for newcomersHelp WantedExtra attention is neededPaper CutA small UX annoyance we should strive to improveWebInvolves web programming (TypeScript, Svelte, CSS)

    Type

    Projects

    • Status
      Short-Term

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions