mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-01 04:38:11 +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:
co-authored by
Keavon Chambers
parent
b60af758a9
commit
0865605f74
@@ -59,6 +59,7 @@
|
|||||||
let self: FieldInput | undefined;
|
let self: FieldInput | undefined;
|
||||||
let inputRangeElement: HTMLInputElement | undefined;
|
let inputRangeElement: HTMLInputElement | undefined;
|
||||||
let text = displayText(value, unit);
|
let text = displayText(value, unit);
|
||||||
|
let isDragging = false;
|
||||||
let editing = false;
|
let editing = false;
|
||||||
// Stays in sync with a binding to the actual input range slider element.
|
// Stays in sync with a binding to the actual input range slider element.
|
||||||
let rangeSliderValue = value !== undefined ? value : 0;
|
let rangeSliderValue = value !== undefined ? value : 0;
|
||||||
@@ -187,6 +188,8 @@
|
|||||||
editing = true;
|
editing = true;
|
||||||
|
|
||||||
self?.selectAllText(text);
|
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
|
// Called only when `value` is changed from the <input> element via user input and committed, either with the
|
||||||
@@ -281,7 +284,7 @@
|
|||||||
const onMove = () => {
|
const onMove = () => {
|
||||||
if (alreadyActedGuard) return;
|
if (alreadyActedGuard) return;
|
||||||
alreadyActedGuard = true;
|
alreadyActedGuard = true;
|
||||||
|
isDragging = true;
|
||||||
beginDrag(e);
|
beginDrag(e);
|
||||||
removeEventListener("pointermove", onMove);
|
removeEventListener("pointermove", onMove);
|
||||||
};
|
};
|
||||||
@@ -289,7 +292,7 @@
|
|||||||
const onUp = () => {
|
const onUp = () => {
|
||||||
if (alreadyActedGuard) return;
|
if (alreadyActedGuard) return;
|
||||||
alreadyActedGuard = true;
|
alreadyActedGuard = true;
|
||||||
|
isDragging = false;
|
||||||
self?.focus();
|
self?.focus();
|
||||||
removeEventListener("pointerup", onUp);
|
removeEventListener("pointerup", onUp);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user