Skip to content

Commit 495b802

Browse files
committed
fixes add new color button
1 parent 4ae946f commit 495b802

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

src/utils/stops.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)