Fix some number input widgets becoming selected after dragging left/right in Firefox (#2250)

* fixes drag

* Cleanup

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
prathmesh703 2025-02-05 13:14:58 +05:30 committed by GitHub
parent b60af758a9
commit 0865605f74
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 2 deletions

View File

@ -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;
@ -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
@ -281,7 +284,7 @@
const onMove = () => {
if (alreadyActedGuard) return;
alreadyActedGuard = true;
isDragging = true;
beginDrag(e);
removeEventListener("pointermove", onMove);
};
@ -289,7 +292,7 @@
const onUp = () => {
if (alreadyActedGuard) return;
alreadyActedGuard = true;
isDragging = false;
self?.focus();
removeEventListener("pointerup", onUp);
};