mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
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:
@@ -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);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user