fix(playground): prevent derived color scale from overriding custom accent color#3269
fix(playground): prevent derived color scale from overriding custom accent color#3269GeekLuffy wants to merge 2 commits into
Conversation
|
@GeekLuffy is attempting to deploy a commit to the Meta Open Source Team on Vercel. A member of the Team first needs to authorize it. |
72b1158 to
e79e8e3
Compare
|
Heads up on the checks here — they're not failing or hung on your end. Because this is a PR from a fork by a first-time contributor, GitHub holds the workflow runs (CI, Lint, Internal Registry) in the A maintainer just needs to hit Approve and run workflows on the Checks tab and they'll execute normally — nothing to change in the code for that. On the fix itself: the diagnosis matches the code path. With "Create from accent" on, an accent edit batches two state updates — the swatch's own |
Thanks for the detailed review! I have implemented your suggestion:
I've pushed the updated commits to the PR branch. Ready for review/approval! |
Summary
This PR fixes a bug in the playground theme editor where toggling "Create from accent" and selecting/typing an accent color causes the input to get "stuck" or automatically shift to a different, derived color (the tone-40/tone-80 HCT tone variant).
Cause
When "Create from accent" is active, changing
--color-accentcallsonExpandColorScale(hex)to derive all semantic scale tokens. However, the derived scale includes a generated--color-accenttoken value (light-dark(P[40], P[80])). When merged back into the React state batch, this derived value overrides the exact custom accent color the user selected or typed in the color swatch.Fix
Deleted
--color-accentfrom thederivedtoken object inhandleExpandColorScale(insideThemeEditor.tsx) before merging it into the token state. This preserves the user's custom accent color selection while successfully generating all other neutral and semantic color tokens from it.Verification
#ff0000 100%) correctly saves and updates without jumping/reverting.npx pnpm buildin the docsite to verify compilation is successful with no errors.Closes #3238