fix(command-palette): eager-inject styles → 0.6.1#14
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Discovered during docs-ai consumption (T27):
CommandPaletteTriggerflashed unstyled until the palette had been opened once. The singleton stylesheet injection lived insidePaletteSurface's mount effect, which only runs onopen=true. The trigger pill mounts long before that.Fix
Call
ensureCommandPaletteStyles()at module-import time (afterCOMMAND_PALETTE_CSSis initialized to dodge TDZ — see the comment block). Thetypeof documentguard inside the helper keeps SSR safe.Verification
pnpm vitest run src/__tests__/components/command-palette/→ 21/21 greenTest plan
<CommandPaletteTrigger>standalone (no<CommandPalette>sibling) — confirm.cp-triggerrules are present in DevTools immediately.