1- import { RefObject , forwardRef , useRef , ReactNode } from 'react' ;
1+ import { RefObject , forwardRef , useRef , ReactNode , useMemo } from 'react' ;
22import { useFocusableRef } from '@react-spectrum/utils' ;
33import { FocusableRef } from '@react-types/shared' ;
44import { useSliderState } from 'react-stately' ;
@@ -7,7 +7,6 @@ import { useSlider, useNumberFormatter } from 'react-aria';
77import { extractStyles , OUTER_STYLES , tasty } from '../../../tasty' ;
88import { useFieldProps , useFormProps , wrapWithField } from '../../form' ;
99import { Text } from '../../content/Text' ;
10- import { mergeProps } from '../../../utils/react' ;
1110
1211import { SliderControlsElement , SliderElement } from './elements' ;
1312
@@ -186,22 +185,17 @@ function SliderBase(
186185 </ LabelValueElement >
187186 ) ;
188187
188+ const mods = useMemo (
189+ ( ) => ( {
190+ 'side-label' : labelPosition === 'side' ,
191+ horizontal : orientation === 'horizontal' ,
192+ } ) ,
193+ [ labelPosition , orientation ] ,
194+ ) ;
195+
189196 const sliderField = (
190- < SliderElement
191- ref = { domRef }
192- { ...groupProps }
193- mods = { {
194- 'side-label' : labelPosition === 'side' ,
195- horizontal : orientation === 'horizontal' ,
196- } }
197- >
198- < SliderControlsElement
199- { ...trackProps }
200- ref = { trackRef }
201- mods = { {
202- horizontal : orientation === 'horizontal' ,
203- } }
204- >
197+ < SliderElement ref = { domRef } { ...groupProps } mods = { mods } >
198+ < SliderControlsElement { ...trackProps } ref = { trackRef } mods = { mods } >
205199 { children ( {
206200 trackRef,
207201 inputRef,
@@ -213,18 +207,13 @@ function SliderBase(
213207
214208 styles = extractStyles ( otherProps , OUTER_STYLES , styles ) ;
215209
216- return wrapWithField (
217- sliderField ,
218- ref ,
219- mergeProps (
220- {
221- ...props ,
222- styles,
223- extra,
224- } ,
225- { labelProps } ,
226- ) ,
227- ) ;
210+ return wrapWithField ( sliderField , ref , {
211+ ...props ,
212+ children : undefined ,
213+ styles,
214+ extra,
215+ labelProps,
216+ } ) ;
228217}
229218
230219const _SliderBase = forwardRef ( SliderBase ) ;
0 commit comments