Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/react/src/ui/hooks/use-slider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ export function useSlider<State extends SliderState = SliderState>(
(element = rootElementRef.current) => {
if (!element) return;

const { dragging, pointing } = slider.input.current;
// Keyboard values come from the controlled state. Applying them here would
// briefly write the previous value before the caller handles the key.
if (!dragging && !pointing) return;

const next = optionsRef.current.computeState(slider.input.current);

applyStyles(element, optionsRef.current.getCSSVars(slider.adjustForAlignment(next)));
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/ui/slider/tests/slider-preview.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const { mockSliderApi } = vi.hoisted(() => ({
},
thumbProps: {
onKeyDownCapture: vi.fn(),
onKeyUpCapture: vi.fn(),
onFocus: vi.fn(),
onBlur: vi.fn(),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const { mockSliderApi, mockThumbnailApi } = vi.hoisted(() => ({
},
thumbProps: {
onKeyDownCapture: vi.fn(),
onKeyUpCapture: vi.fn(),
onFocus: vi.fn(),
onBlur: vi.fn(),
},
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/ui/slider/tests/slider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const { mockSliderApi, sliderOptionsRef } = vi.hoisted(() => {
},
thumbProps: {
onKeyDownCapture: (event: { preventDefault(): void }) => event.preventDefault(),
onKeyUpCapture: vi.fn(),
onFocus: vi.fn(),
onBlur: vi.fn(),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const {
},
thumbProps: {
onKeyDownCapture: vi.fn(),
onKeyUpCapture: vi.fn(),
onFocus: vi.fn(),
onBlur: vi.fn(),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const { mockSliderApi, mockVolumeState, mutableVolume } = vi.hoisted(() => {
},
thumbProps: {
onKeyDownCapture: vi.fn(),
onKeyUpCapture: vi.fn(),
onFocus: vi.fn(),
onBlur: vi.fn(),
},
Expand Down
Loading