🟫 fix: Reject Invalid Hex Color Matches (#15744)

`dev` is red on `Tests: @librechat/client`. The comment I added in #15738
cites the pull request that pinned `react-dialog` as `(#11023)`, and the
shared-component guardrail's `/#[0-9a-f]{3,8}\b/i` reads five hex-range
digits as a color. Every branch built on dev inherits the failure.

Fixed on both sides: the comment cites the number without the `#`, and the
pattern now matches only CSS-legal hex lengths (3, 4, 6, 8), so no issue
reference can trip it again. The guardrail keeps its teeth — the same test
now asserts it still matches `#fff`, `#ff0000` and `#aabbccdd`, and leaves
"closes #15738" alone.

Also relaxes one assertion in `popoverLayering.spec.tsx`: it pinned the
ABSENCE of an inline `pointer-events` on a hover card outside any dialog,
which is Radix's to set, not the hook's. Whether a sibling select's
`disableOutsidePointerEvents` reaches that card depends on whether the two
share a copy of `react-dismissable-layer` — a packaging fact that changes
under #15742. The test now asserts only what the hook itself contributes.
This commit is contained in:
Danny Avila 2026-09-08 12:07:46 -04:00 • committed by GitHub
parent 3bff323ac8
commit 57ebbe13e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 20 additions and 5 deletions

View file

@ -29,7 +29,7 @@ export const usePopoverZIndex = (): number => {
*
* Radix coordinates nested layers through module-level state, so it only
* coordinates layers from the *same copy* of `react-dismissable-layer`. This
* app has three: `react-dialog` is pinned at 1.0.2 (#11023) while `react-select`
* app has three: `react-dialog` is pinned at 1.0.2 (see PR 11023) while `react-select`
* and `react-hover-card` resolve to their own newer copies. A popover therefore
* never learns that the dialog disabled body pointer events, and never lifts
* itself over the dialog — it opens behind an opaque overlay, inert.

View file

@ -77,8 +77,12 @@ describe('portaled popovers inside a dialog', () => {
/** Outside a dialog the CSS layer still decides, so a consumer that raises it
* by class — `z-[999]` to clear the legacy `Dialog` — keeps that override.
* Radix still owns `pointer-events` there: a select disables outside pointer
* events for its own layer stack whether or not a dialog is involved. */
*
* Only the absence of OUR inline z-index is asserted. `pointer-events` is
* Radix's to set out here: a select disables outside pointer events for its
* own layer stack, and whether a sibling popover then reads `auto` depends
* on whether the two share a copy of `react-dismissable-layer` — which is a
* packaging fact, not this hook's contract. */
it('leaves the CSS layer alone outside any dialog', () => {
render(
<>
@ -92,7 +96,6 @@ describe('portaled popovers inside a dialog', () => {
expect(listbox.style.zIndex).toBe('');
expect(listbox).toHaveClass('z-40');
expect(card.style.zIndex).toBe('');
expect(card.style.pointerEvents).toBe('');
expect(card).toHaveClass('z-50');
});
});

View file

@ -33,7 +33,11 @@ describe('shared component color guardrail', () => {
it('keeps shared primitives free of direct palette utilities and hex colors', () => {
const directPalette =
/(?:bg|text|border|ring|from|via|to)-(?:gray|red|green|blue|purple|amber|yellow|orange|pink|indigo|violet|teal|cyan|slate|zinc|neutral|stone)-\d/;
const hexColor = /#[0-9a-f]{3,8}\b/i;
/** Only CSS-legal hex lengths (3, 4, 6, 8). `{3,8}` also matched a five-
* digit issue reference in a comment — see the PR number in
* `OriginalDialog.tsx` — which reads as a color to a regex and to nobody
* else. */
const hexColor = /#(?:[0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})\b/i;
sharedComponents.forEach((component) => {
const source = readFileSync(join(__dirname, '..', 'components', component), 'utf8');
@ -41,6 +45,14 @@ describe('shared component color guardrail', () => {
expect(source).not.toMatch(directPalette);
expect(source).not.toMatch(hexColor);
});
/** The guardrail still has to catch what it exists for. */
expect('bg-surface-primary text-[#ff0000]').toMatch(hexColor);
expect('color: #fff;').toMatch(hexColor);
expect('#aabbccdd').toMatch(hexColor);
/** …and leave prose alone: an issue reference is not a color. */
expect('pinned by #11023').not.toMatch(hexColor);
expect('closes #15738').not.toMatch(hexColor);
});
it('keeps every shared dialog shell on the semantic dialog surface', () => {