@@ -121,6 +121,10 @@ const AdvancedRangeControl = props => {
121121
122122 // On reset, allow overriding the value.
123123 if ( newValue === '' ) {
124+ // Reset should also change from mark mode
125+ if ( isMarkMode ) {
126+ setIsMarkMode ( false )
127+ }
124128 const overrideValue = props . onOverrideReset ?. ( )
125129 if ( typeof overrideValue !== 'undefined' ) {
126130 newValue = overrideValue
@@ -144,18 +148,18 @@ const AdvancedRangeControl = props => {
144148 propsToPass . sliderMax = props . marks . length - 1
145149 propsToPass . step = 1
146150
147- // Show the marks and labels
151+ // Show the marks and names
148152 propsToPass . marks = props . marks . reduce ( ( acc , mark , index ) => {
149153 return [
150154 {
151155 value : index ,
152- label : undefined ,
156+ name : undefined ,
153157 } ,
154158 ...acc ,
155159 ]
156160 } , [ ] )
157161 propsToPass . renderTooltipContent = value => {
158- return props . marks [ value ] ?. label || ''
162+ return props . marks [ value ] ?. name || ''
159163 }
160164
161165 // Other necessary props for steps.
@@ -171,6 +175,11 @@ const AdvancedRangeControl = props => {
171175 controlProps . className += isMarkMode ? ' stk-range-control--mark-mode' : ''
172176 }
173177
178+ if ( props . isCustomPreset ) {
179+ controlProps . className = controlProps . className || ''
180+ controlProps . className += 'stk-preset-controls'
181+ }
182+
174183 // We need to change the way we handle the value and onChange if we're doing marks
175184 let rangeValue = propsToPass . isDynamic || props . hasCSSVariableValue ? parseFloat ( derivedValue ) : derivedValue
176185 let rangeOnChange = _onChange
@@ -227,17 +236,22 @@ const AdvancedRangeControl = props => {
227236 </ RangeControl >
228237 </ DynamicContentControl >
229238 < ResetButton
239+ // Allow running own reset for custom preset controls since
240+ // unit is also needed to be reset
230241 allowReset = { props . allowReset }
242+ showReset = { props . showReset }
231243 value = { derivedValue }
232244 default = { props . default }
233- onChange = { _onChange }
245+ onChange = { props . onReset ? props . onReset : _onChange }
234246 />
235247 </ AdvancedControl >
236248 )
237249}
238250
239251AdvancedRangeControl . defaultProps = {
240252 allowReset : true ,
253+ onReset : undefined ,
254+ showReset : undefined ,
241255 isDynamic : false ,
242256 default : '' ,
243257
@@ -250,9 +264,10 @@ AdvancedRangeControl.defaultProps = {
250264 onOverrideReset : undefined ,
251265 forcePlaceholder : false ,
252266
253- marks : undefined , // [{ value: '14px', label : 'S' }, { value: '16px', label : 'M' }]
267+ marks : undefined , // [{ value: '14px', name : 'S' }, { value: '16px', name : 'M' }]
254268 allowCustom : true ,
255269 hasCSSVariableValue : false ,
270+ isCustomPreset : false ,
256271}
257272
258273export default memo ( AdvancedRangeControl , isEqual )
0 commit comments