Skip to content

Fix "Stripes" preset span positions collapsing on repeated updateStops calls#127

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-clear-issue-with-elegance
Draft

Fix "Stripes" preset span positions collapsing on repeated updateStops calls#127
Copilot wants to merge 3 commits intomainfrom
copilot/fix-clear-issue-with-elegance

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 25, 2026

The hadLinked heuristic in updateStops incorrectly treated explicit span end-positions (e.g. 0% 20%) as auto-linked pairs on any call after the first, collapsing them to 0% 0%. This rendered the Stripes preset as solid black after the first user interaction with the overlay.

Root cause

After the initial updateStops pass, stop.auto is set to the computed auto value (e.g. 20 for a stop at index 2). On the next call, position2 = '20' matched prevAuto = 20, triggering hadLinked = true and overwriting position2 ← position1 = '0':

// Before fix: prevAuto condition fires regardless of whether p1 is auto-managed
const hadLinked = (!p2Unset) && (
  String(stop.position2) === String(stop.position1) ||
  (prevAuto != null && String(stop.position2) === String(prevAuto))  // ← false positive
)

Fix

Guard the prevAuto branch with p1Unset — a stop's position2 should only be considered "linked to auto" when position1 is also auto-managed:

const hadLinked = (!p2Unset) && (
  String(stop.position2) === String(stop.position1) ||
  (p1Unset && prevAuto != null && String(stop.position2) === String(prevAuto))
)

This preserves explicit spans like #000 0% 20% across repeated updateStops calls while keeping the redistribution linkage intact for fully auto-managed stop pairs.

Tests

Added src/lib/stripesIssue.test.ts covering idempotency of span positions across multiple updateStops calls and correct CSS output after re-normalization.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 25, 2026

Deploy Preview for hd-gradients ready!

Name Link
🔨 Latest commit da91b38
🔍 Latest deploy log https://app.netlify.com/projects/hd-gradients/deploys/699e93c6ed7d750008e743ff
😎 Deploy Preview https://deploy-preview-127--hd-gradients.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI changed the title [WIP] Fix clear issue with minimal changes Fix "Stripes" preset span positions collapsing on repeated updateStops calls Feb 25, 2026
Copilot AI requested a review from argyleink February 25, 2026 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants