Skip to content

Commit ba4ef59

Browse files
committed
fix(rich-markdown-editor): close the semantic-Tailwind-color gap in the mention-chip test
Greptile: the color-shaped regex still missed semantic theme tokens (text-primary, text-muted-foreground, text-chart-1, etc.) since they don't match a shade-suffix or bracket pattern. Rather than keep enumerating Tailwind's color-naming schemes, flag ANY unscoped text-* utility on the wrapper — none is legitimate on this chip today, so this can only be a color slipping back in. Verified against text-primary/text-muted-foreground/text-chart-1 regressions.
1 parent 9465362 commit ba4ef59

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

  • apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/mention

apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/mention/mention-chip.test.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,17 @@ describe('MentionChipView', () => {
6161
const chip = container.querySelector('.mention-chip') as HTMLElement
6262
expect(chip).not.toBeNull()
6363

64-
// Any bare (non-descendant-scoped) `text-*` color utility on the wrapper itself would
65-
// regress this fix, not just the specific old `text-[var(--text-primary)]` class — a future
66-
// edit swapping it for e.g. `text-[var(--text-secondary)]` or `text-blue-500` would still
67-
// silently override ambient color and must fail this test too.
68-
const ownColorUtilities = chip.className
64+
// Any bare (non-descendant-scoped) `text-*` utility on the wrapper itself would regress this
65+
// fix — not just the specific old `text-[var(--text-primary)]` class. Rather than enumerate
66+
// every Tailwind color-naming scheme (arbitrary value, shade-suffixed, semantic theme tokens
67+
// like `text-primary`/`text-muted-foreground`, keywords), flag ANY unscoped `text-*` token:
68+
// none is legitimate on this wrapper today, so this can only ever be a color utility slipping
69+
// back in. A genuinely new, non-color `text-*` need (e.g. a font-size utility) should fail this
70+
// test and force an explicit update, not be silently allowed through.
71+
const ownTextUtilities = chip.className
6972
.split(/\s+/)
70-
.filter(
71-
(cls) =>
72-
!cls.startsWith('[&') &&
73-
/^text-(\[.+\]|[a-z]+-\d{2,3}|black|white|current|transparent|inherit)$/.test(cls)
74-
)
75-
expect(ownColorUtilities).toEqual([])
73+
.filter((cls) => !cls.startsWith('[&') && cls.startsWith('text-'))
74+
expect(ownTextUtilities).toEqual([])
7675

7776
// The icon's own monochrome fallback is unrelated and must be untouched by this fix.
7877
expect(chip.className).toContain('[&>svg]:text-[var(--text-icon)]')

0 commit comments

Comments
 (0)