Skip to content

Commit 0f4c023

Browse files
committed
Use activeElement
1 parent 65eae8d commit 0f4c023

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/react/src/slider/root/useSliderRoot.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,14 @@ export function focusThumb(
7272
return;
7373
}
7474

75-
const doc = ownerDocument(sliderRef.current);
75+
const activeEl = activeElement(ownerDocument(sliderRef.current));
7676

7777
if (
78-
!sliderRef.current.contains(doc.activeElement) ||
79-
Number(doc?.activeElement?.getAttribute(SliderThumbDataAttributes.index)) !== thumbIndex
78+
activeEl == null ||
79+
!sliderRef.current.contains(activeEl) ||
80+
Number(activeEl.getAttribute(SliderThumbDataAttributes.index)) !== thumbIndex
8081
) {
82+
// TODO: possibly simplify with thumbRefs as it already exists
8183
(
8284
sliderRef.current.querySelector(
8385
`[type="range"][${SliderThumbDataAttributes.index}="${thumbIndex}"]`,

0 commit comments

Comments
 (0)