fix: stop the text palette slug from hijacking every custom colour

theme.json shipped a palette entry with the slug "text", so WordPress
generated `.has-text-color { color: var(--wp--preset--color--text)
!important }`. The block editor puts that same class on any block given a
custom text colour, so the rule overrode every one of them site-wide with
the dark-theme foreground, unreadable in either theme. An !important
declaration beats an inline style, which is why the colour set on the
block never had a chance.

Rename the slug to "foreground". No published content used the class, for
the obvious reason that it never worked, so nothing has to be migrated.
A smoke test now rejects any palette slug that shadows an editor utility
class.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
chrnxandClaude Opus 5 committed 2026-08-14 10:21:23 -05:00
1 parent 13a8b0425f
commit 6dc4de6b8e
27 files changed
+308 -185

No files matched your search

+17 -1
View File
@@ -112,7 +112,7 @@ test('theme.json exposes the complete dark and warm-light palette with stable se
panel: '#161B22',
violet: '#7C6CF0',
green: '#5FB88A',
text: '#E6EDF3',
foreground: '#E6EDF3',
muted: '#8B949E',
paper: '#F6F2E9',
surface: '#FFFDF7',
@@ -126,6 +126,22 @@ test('theme.json exposes the complete dark and warm-light palette with stable se
assert.deepEqual(palette, expectedTokens);
});
test('no palette slug collides with a block editor utility class', async () => {
const theme = JSON.parse(await readProjectFile('theme.json'));
/*
* WordPress emits `.has-<slug>-color { color: ... !important }` for every
* palette entry. The editor adds the class `has-text-color` to any block
* carrying a custom text colour, so a slug named "text" produced a rule
* that overrode every custom colour on the site with the preset value.
*/
const reserved = new Set(['text', 'background', 'link']);
const collisions = theme.settings.color.palette
.map(({ slug }) => slug)
.filter((slug) => reserved.has(slug));
assert.deepEqual(collisions, []);
});
test('the local Zen Maru Gothic files and license are present', async () => {
await Promise.all([
'assets/fonts/zen-maru-gothic-latin-500.woff2',