@@ -390,6 +411,8 @@ export function FlatSlider({
onPointerDown={(e) => {
if (disabled) return;
draggingRef.current = true;
+ dragStartValueRef.current = latestValueRef.current;
+ activePointerIdRef.current = e.pointerId;
e.currentTarget.setPointerCapture(e.pointerId);
const stepped = stepFromClientX(e.clientX, e.currentTarget.getBoundingClientRect());
setDraft(stepped);
@@ -447,12 +470,25 @@ export function FlatSlider({
}}
onKeyDown={(e) => {
if (disabled) return;
+ if (e.key === "Escape" && draggingRef.current) {
+ e.preventDefault();
+ cancelDrag(e.currentTarget);
+ return;
+ }
const next = sliderKeyTarget(e.key, draft, min, max, step);
if (next === null) return;
e.preventDefault();
setDraft(next);
commitDraft(next);
}}
+ onContextMenu={(e) => {
+ // Right-click during a drag must cancel it (revert to the pre-drag
+ // value), not leave the last dragged-to position committed while
+ // the native context menu opens on top of the slider.
+ if (!draggingRef.current) return;
+ e.preventDefault();
+ cancelDrag(e.currentTarget);
+ }}
>
{centerTick && (
@@ -505,88 +541,4 @@ export function FlatSlider({
);
}
-/* ------------------------------------------------------------------ */
-/* FlatSelectRow — label/value row backed by a native