@@ -3,25 +3,36 @@ export function updateStops(stops) {
33
44 let updated = stops . map ( ( stop , i ) => {
55 let autoVal = autoStops [ i ]
6-
6+
77 if ( stop . kind == 'stop' ) {
88 if ( stops . length === 1 ) {
9+ // For a single color stop, span the entire line
910 stop . position1 = 0
10- stop . position2 = 100
11+ stop . position2 = 100
1112 }
12- else if ( ! stop . _manual && ( ! stop . position1 || stop . position1 === stop . auto ) ) {
13- stop . position1 = autoVal
14- stop . position2 = autoVal
13+ else if ( ! stop . _manual ) {
14+ // 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 ) )
16+ const p2UnsetOrAuto = ( stop . position2 == null ) || ( stop . auto != null && String ( stop . position2 ) == String ( stop . auto ) )
17+
18+ // Only assign auto for position1 when it is unset or previously auto-managed
19+ if ( p1Unset ) stop . position1 = autoVal
20+
21+ // Only assign auto for position2 when it's unset or previously auto-managed.
22+ // Preserve any explicitly provided second position (e.g., from presets) to avoid regressions.
23+ if ( p2UnsetOrAuto ) stop . position2 = p1Unset ? autoVal : stop . position1
1524 }
1625 // Clear the manual flag after one normalization pass so future edits behave normally
1726 if ( stop . _manual ) delete stop . _manual
1827 }
1928 // is a hint
2029 else {
21- if ( ! stop . percentage || stop . percentage === stop . auto )
30+ // Only auto-assign hint percentage when it's unset or previously auto-managed
31+ if ( stop . percentage == null || ( stop . auto != null && String ( stop . percentage ) == String ( stop . auto ) ) )
2232 stop . percentage = autoVal
2333 }
2434
35+ // Persist the computed auto value for future comparisons
2536 stop . auto = autoVal
2637 return stop
2738 } )
0 commit comments