Skip to content

Commit

Permalink
Fix some number input widgets becoming selected after dragging left/r…
Browse files Browse the repository at this point in the history
…ight in Firefox (#2250)

* fixes drag

* Cleanup

---------

Co-authored-by: Keavon Chambers <[email protected]>
  • Loading branch information
prathmesh703 and Keavon authored Feb 5, 2025
1 parent b60af75 commit 0865605
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions frontend/src/components/widgets/inputs/NumberInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
let self: FieldInput | undefined;
let inputRangeElement: HTMLInputElement | undefined;
let text = displayText(value, unit);
let isDragging = false;
let editing = false;
// Stays in sync with a binding to the actual input range slider element.
let rangeSliderValue = value !== undefined ? value : 0;
Expand Down Expand Up @@ -187,6 +188,8 @@
editing = true;
self?.selectAllText(text);
// Workaround for weird behavior in Firefox: <https://github.com/GraphiteEditor/Graphite/issues/2215>
if (isDragging) self?.unFocus();
}
// Called only when `value` is changed from the <input> element via user input and committed, either with the
Expand Down Expand Up @@ -281,15 +284,15 @@
const onMove = () => {
if (alreadyActedGuard) return;
alreadyActedGuard = true;
isDragging = true;
beginDrag(e);
removeEventListener("pointermove", onMove);
};
// If it's a mouseup, we'll begin editing the text field.
const onUp = () => {
if (alreadyActedGuard) return;
alreadyActedGuard = true;
isDragging = false;
self?.focus();
removeEventListener("pointerup", onUp);
};
Expand Down

0 comments on commit 0865605

Please sign in to comment.