Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(slider): end the drag on a cancelled touch too

EtienneLescotd125fc829dc7
diff --git a/src/components/ai-edition/RightPanes.tsx b/src/components/ai-edition/RightPanes.tsx
index 4b893f584..45821a645 100644
--- a/src/components/ai-edition/RightPanes.tsx
+++ b/src/components/ai-edition/RightPanes.tsx
@@ -4106,8 +4106,11 @@ export function SliderCell({
title={hint}
style={{ "--slider-pct": `${pct}%` } as CSSProperties}
onChange={(e) => onChange(Number(e.target.value))}
+ // A mouse released off the slider needs nothing more: the browser captures a range
+ // drag, so its mouseup still lands here. A touch the system cancels ends it too.
onMouseUp={onCommit}
onTouchEnd={onCommit}
+ onTouchCancel={onCommit}
onKeyUp={onCommit}
/>
</div>
diff --git a/src/components/ai-edition/roundnessUnderFrame.test.tsx b/src/components/ai-edition/roundnessUnderFrame.test.tsx
index 1c429f944..88da1a8f7 100644
--- a/src/components/ai-edition/roundnessUnderFrame.test.tsx
+++ b/src/components/ai-edition/roundnessUnderFrame.test.tsx
@@ -80,6 +80,13 @@ describe("Roundness at zero padding", () => {
expect(roundness()).not.toBeInTheDocument();
});
+ it("leaves on a cancelled touch as on a release", () => {
+ mount({ padding: 30, borderRadius: 20 });
+ fireEvent.change(padding(), { target: { value: "0" } });
+ fireEvent.touchCancel(padding());
+ expect(roundness()).not.toBeInTheDocument();
+ });
+
it("comes back with its value, on the release of a drag up from 0", () => {
// Added mid-drag, the row could tip the pane into overflow, and the scrollbar that came
// with it narrowed the pane and moved the slider under the pointer.