File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,15 +12,27 @@ export function updateStops(stops) {
1212 }
1313 else if ( ! stop . _manual ) {
1414 // Treat null/undefined as unset; 0 is a valid value and must be preserved
15- const p1Unset = ( stop . position1 == null ) || ( stop . auto != null && String ( stop . position1 ) == String ( stop . auto ) )
15+ const prevAuto = stop . auto
16+ const p1Unset = ( stop . position1 == null ) || ( prevAuto != null && String ( stop . position1 ) == String ( prevAuto ) )
1617 const p2Unset = ( stop . position2 == null )
1718
19+ // Detect whether position2 was effectively "linked" to position1 or to the prior auto value
20+ const hadLinked = ( ! p2Unset ) && (
21+ String ( stop . position2 ) === String ( stop . position1 ) ||
22+ ( prevAuto != null && String ( stop . position2 ) === String ( prevAuto ) )
23+ )
24+
1825 // Only assign auto for position1 when it is unset or previously auto-managed
1926 if ( p1Unset ) stop . position1 = autoVal
2027
2128 // Only assign a second position when it is truly unset. Never override an existing value,
2229 // even if it equals the auto position, to preserve explicit spans from presets/URL restores.
23- if ( p2Unset ) stop . position2 = p1Unset ? autoVal : stop . position1
30+ if ( p2Unset ) {
31+ stop . position2 = p1Unset ? autoVal : stop . position1
32+ } else if ( hadLinked ) {
33+ // Maintain linkage when redistributing: keep position2 equal to position1
34+ stop . position2 = ( stop . position1 != null ) ? stop . position1 : autoVal
35+ }
2436 }
2537 // Clear the manual flag after one normalization pass so future edits behave normally
2638 if ( stop . _manual ) delete stop . _manual
You can’t perform that action at this time.
0 commit comments