Skip to content

Commit 60acf60

Browse files
committed
fix: slider disabled
1 parent b26668c commit 60acf60

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@zag-js/slider": patch
3+
---
4+
5+
Fix issue where slider continues dragging when disabled during drag operation.

packages/machines/slider/src/slider.machine.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,16 @@ export const machine = createMachine<SliderSchema>({
101101
),
102102
},
103103

104-
watch({ track, action, context }) {
104+
watch({ track, action, context, computed, send }) {
105105
track([() => context.hash("value")], () => {
106106
action(["syncInputElements", "dispatchChangeEvent"])
107107
})
108+
109+
track([() => computed("isDisabled")], () => {
110+
if (computed("isDisabled")) {
111+
send({ type: "BLUR" })
112+
}
113+
})
108114
},
109115

110116
effects: ["trackFormControlState", "trackThumbSize"],
@@ -186,6 +192,10 @@ export const machine = createMachine<SliderSchema>({
186192
POINTER_MOVE: {
187193
actions: ["setPointerValue"],
188194
},
195+
BLUR: {
196+
target: "idle",
197+
actions: ["clearFocusedIndex"],
198+
},
189199
},
190200
},
191201
},

0 commit comments

Comments
 (0)