@@ -10,9 +10,9 @@ import {
1010 unstable_useForkRef as useForkRef ,
1111 unstable_useControlled as useControlled ,
1212} from '@material-ui/utils' ;
13+ import { visuallyHidden } from '@material-ui/system' ;
1314import isHostComponent from '../utils/isHostComponent' ;
1415import sliderUnstyledClasses from './sliderUnstyledClasses' ;
15- import { visuallyHidden } from '@material-ui/system' ;
1616import SliderValueLabelUnstyled from './SliderValueLabelUnstyled' ;
1717
1818function asc ( a , b ) {
@@ -308,19 +308,13 @@ const SliderUnstyled = React.forwardRef(function SliderUnstyled(props, ref) {
308308 const marksValues = marks . map ( ( mark ) => mark . value ) ;
309309 const marksIndex = marksValues . indexOf ( value ) ;
310310
311- // TODO this might need to use roundValueToStep instead or something
312- // but since the native input respects the step it doesn't look like we need it
313311 let newValue = event . target . valueAsNumber ;
314- // TODO add test to make sure when value/step is -4e-8 it still works
315312
316313 if ( marks && step == null ) {
317- newValue =
318- newValue < value
319- ? marksValues [ marksIndex - 1 ]
320- : marksValues [ marksIndex + 1 ] ;
314+ newValue = newValue < value ? marksValues [ marksIndex - 1 ] : marksValues [ marksIndex + 1 ] ;
321315 }
322316
323- newValue = clamp ( newValue , min , max ) ; // todo might not be needed since input won't allow it to go outside
317+ newValue = clamp ( newValue , min , max ) ;
324318
325319 if ( range ) {
326320 const previousValue = newValue ;
@@ -613,8 +607,6 @@ const SliderUnstyled = React.forwardRef(function SliderUnstyled(props, ref) {
613607 className = { clsx ( utilityClasses . track , trackProps . className ) }
614608 style = { { ...trackStyle , ...trackProps . style } }
615609 />
616- { /* TODO possibly remove? Need to figure out how to handle name on real hidden range field, and what this is usually used for */ }
617- < input value = { values . join ( ',' ) } name = { name } type = "hidden" />
618610 { marks . map ( ( mark , index ) => {
619611 const percent = valueToPercent ( mark . value , min , max ) ;
620612 const style = axisProps [ axis ] . offset ( percent ) ;
@@ -678,7 +670,7 @@ const SliderUnstyled = React.forwardRef(function SliderUnstyled(props, ref) {
678670 < React . Fragment key = { index } >
679671 < input
680672 data-index = { index }
681- aria-label = { getAriaLabel ? getAriaLabel ( index ) : ariaLabel } // TODO figure out how to message in multi thumb mode
673+ aria-label = { getAriaLabel ? getAriaLabel ( index ) : ariaLabel }
682674 aria-labelledby = { ariaLabelledby }
683675 aria-orientation = { orientation }
684676 aria-valuemax = { scale ( max ) }
@@ -689,7 +681,7 @@ const SliderUnstyled = React.forwardRef(function SliderUnstyled(props, ref) {
689681 }
690682 onFocus = { handleFocus }
691683 onBlur = { handleBlur }
692- name = { name } // TODO this will have to be dynamic for multi thumb version?
684+ name = { name }
693685 type = "range"
694686 min = { props . min }
695687 max = { props . max }
@@ -717,21 +709,21 @@ const SliderUnstyled = React.forwardRef(function SliderUnstyled(props, ref) {
717709 theme,
718710 } ) }
719711 >
720- < Thumb
721- data-index = { index }
722- onMouseOver = { handleMouseOver }
723- onMouseLeave = { handleMouseLeave }
724- { ...thumbProps }
725- className = { clsx ( utilityClasses . thumb , thumbProps . className , {
726- [ sliderUnstyledClasses [ 'active' ] ] : active === index ,
727- [ sliderUnstyledClasses [ 'disabled' ] ] : disabled ,
728- [ sliderUnstyledClasses [ 'focusVisible' ] ] : focusVisible === index ,
729- } ) }
730- { ...( ! isHostComponent ( Thumb ) && {
731- styleProps : { ...stateAndProps , ...thumbProps . styleProps } ,
732- theme,
733- } ) }
734- style = { { ...style , ...thumbProps . style } }
712+ < Thumb
713+ data-index = { index }
714+ onMouseOver = { handleMouseOver }
715+ onMouseLeave = { handleMouseLeave }
716+ { ...thumbProps }
717+ className = { clsx ( utilityClasses . thumb , thumbProps . className , {
718+ [ sliderUnstyledClasses [ 'active' ] ] : active === index ,
719+ [ sliderUnstyledClasses [ 'disabled' ] ] : disabled ,
720+ [ sliderUnstyledClasses [ 'focusVisible' ] ] : focusVisible === index ,
721+ } ) }
722+ { ...( ! isHostComponent ( Thumb ) && {
723+ styleProps : { ...stateAndProps , ...thumbProps . styleProps } ,
724+ theme,
725+ } ) }
726+ style = { { ...style , ...thumbProps . style } }
735727 />
736728 </ ValueLabelComponent >
737729 </ React . Fragment >
0 commit comments