File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed
Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -192,8 +192,15 @@ const AdvancedRangeControl = props => {
192192 let rangeOnChange = _onChange
193193 if ( isMarkMode ) {
194194 rangeValue = props . marks . findIndex ( mark => {
195- const [ _value , _unit ] = extractNumbersAndUnits ( mark . value ) [ 0 ]
196- return _value === derivedValue
195+ let _unit , _value
196+ // If the derivedValue is a CSS variable, compare with mark's CSS variable.
197+ // Otherwise, the derivedValue is custom, so compare with raw size and units
198+ if ( typeof derivedValue === 'string' && derivedValue . startsWith ( 'var' ) ) {
199+ [ _value , _unit ] = extractNumbersAndUnits ( mark . value ) [ 0 ]
200+ } else {
201+ [ _value , _unit ] = extractNumbersAndUnits ( mark . size ) [ 0 ]
202+ }
203+ return _value === derivedValue && ( _unit === '' || _unit === unit )
197204 } )
198205 rangeOnChange = ( value , property = 'value' ) => {
199206 if ( value === '' ) {
Original file line number Diff line number Diff line change @@ -349,8 +349,15 @@ const FourRangeControl = memo( props => {
349349 let rangeOnChange = initialOnChange
350350 if ( props . marks && isMarkMode ) {
351351 rangeValue = props . marks . findIndex ( mark => {
352- const [ _value , _unit ] = extractNumbersAndUnits ( mark . value ) [ 0 ]
353- return _value === initialValue
352+ let _unit , _value
353+ // If the initialValue is a CSS variable, compare with mark's CSS variable.
354+ // Otherwise, the initialValue is custom, so compare with raw size and units
355+ if ( typeof initialValue === 'string' && initialValue . startsWith ( 'var' ) ) {
356+ [ _value , _unit ] = extractNumbersAndUnits ( mark . value ) [ 0 ]
357+ } else {
358+ [ _value , _unit ] = extractNumbersAndUnits ( mark . size ) [ 0 ]
359+ }
360+ return _value === initialValue && ( _unit === '' || _unit === unit )
354361 } )
355362 rangeOnChange = ( value , property = 'value' ) => {
356363 if ( value === '' ) {
You can’t perform that action at this time.
0 commit comments