Skip to content

fix(command-palette): eager-inject styles → 0.6.1#14

Merged
A-PachecoT merged 1 commit into
mainfrom
fix/eager-inject-styles
May 22, 2026
Merged

fix(command-palette): eager-inject styles → 0.6.1#14
A-PachecoT merged 1 commit into
mainfrom
fix/eager-inject-styles

Conversation

@A-PachecoT

Copy link
Copy Markdown
Contributor

Summary

Discovered during docs-ai consumption (T27): CommandPaletteTrigger flashed unstyled until the palette had been opened once. The singleton stylesheet injection lived inside PaletteSurface's mount effect, which only runs on open=true. The trigger pill mounts long before that.

Fix

Call ensureCommandPaletteStyles() at module-import time (after COMMAND_PALETTE_CSS is initialized to dodge TDZ — see the comment block). The typeof document guard inside the helper keeps SSR safe.

Verification

  • pnpm vitest run src/__tests__/components/command-palette/ → 21/21 green
  • Trigger now renders styled on first paint, regardless of palette state.

Test plan

  • Manual: render <CommandPaletteTrigger> standalone (no <CommandPalette> sibling) — confirm .cp-trigger rules are present in DevTools immediately.

…n first paint [0.6.1]

CommandPaletteTrigger flashed unstyled until the palette was opened once,
because the singleton <style id="cp-styles"> injection was inside
PaletteSurface's mount effect — which only fires on open=true. The trigger
pill mounts long before then.

Fix: call ensureCommandPaletteStyles() at module-import time (after
COMMAND_PALETTE_CSS is initialized — avoids TDZ — behind the
`typeof document` guard inside the helper, so SSR stays safe).

Trigger now renders styled from the first paint regardless of palette state.
21/21 palette tests still pass.
@A-PachecoT A-PachecoT merged commit 2338203 into main May 22, 2026
1 of 2 checks passed
@A-PachecoT A-PachecoT deleted the fix/eager-inject-styles branch May 22, 2026 18:41
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.

1 participant