Skip to content

Commit

Permalink
Fix: Allow root slot refs to merge with focus refs in Slider (microso…
Browse files Browse the repository at this point in the history
…ft#26243)

* fix: allow refs passed in root slot to merge with focus refs

* change file

* cleanup
  • Loading branch information
micahgodbolt authored and q1b committed Jan 24, 2023
1 parent 65a3c2a commit 2eb4fb7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: allow refs passed in root slot to merge with focus refs",
"packageName": "@fluentui/react-slider",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { getPartitionedNativeProps, resolveShorthand, useId } from '@fluentui/react-utilities';
import { getPartitionedNativeProps, resolveShorthand, useId, useMergedRefs } from '@fluentui/react-utilities';
import { useSliderState_unstable } from './useSliderState';
import { SliderProps, SliderState } from './Slider.types';
import { useFocusWithin } from '@fluentui/react-tabster';
Expand Down Expand Up @@ -34,10 +34,7 @@ export const useSlider_unstable = (props: SliderProps, ref: React.Ref<HTMLInputE
},
root: resolveShorthand(root, {
required: true,
defaultProps: {
ref: useFocusWithin<HTMLDivElement>(),
...nativeProps.root,
},
defaultProps: nativeProps.root,
}),
input: resolveShorthand(input, {
required: true,
Expand All @@ -53,6 +50,8 @@ export const useSlider_unstable = (props: SliderProps, ref: React.Ref<HTMLInputE
thumb: resolveShorthand(thumb, { required: true }),
};

state.root.ref = useMergedRefs(state.root.ref, useFocusWithin<HTMLDivElement>());

useSliderState_unstable(state, props);

return state;
Expand Down

0 comments on commit 2eb4fb7

Please sign in to comment.