Narrow the remaining Chat components to curated props - #440
Merged
Conversation
The eight Chat components outside the button pair still extended ComponentPropsWithoutRef and spread `...rest` onto their root, so they accepted the whole DOM prop surface — including props that fight their own contract (`role`, `aria-live`, `data-sender`) with no indication which one wins. Introduce `ChatPassthroughProps` — id plus the three aria naming and description attributes — and extend each component with it, mirroring `ButtonPassthroughProps` from #438. ChatComposerInput is a textarea, so it adds the text-input props a chat composer actually needs on top: autoComplete, enterKeyHint, maxLength, name, onBlur, onFocus, onPaste, and onKeyDown (which the component already consumed but only declared via the wide extension). Two behavior fixes fall out of the narrowing: - ChatMessage spread `...rest` before its generated `aria-label` / `aria-labelledby`, so a consumer label was silently dropped. The consumer's value now wins and falls back to the generated one. - ChatMessageList hardcoded `aria-live="polite"` with no way to opt out; it is now a prop defaulting to `polite`. Fixes #439 Claude-Session: https://claude.ai/code/session_01XFkkvUQfynGRedEYDNxKoY
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Fixes #439. Follow-up to #438, applying the same curated-props treatment to the rest of the Chat directory.
ChatPassthroughPropsThe identity and description props every Chat container forwards to its root:
Applied to
ChatLayout,ChatComposer,ChatMessage,ChatMessageList,ChatMessageBubble,ChatMessageMetadata, andChatSystemMessage— replacingComponentPropsWithoutRef<'div' | 'article'>in each.ChatComposerInputis a textarea, so it extends the shared set with the text-input props a chat composer actually needs:autoComplete,enterKeyHint,maxLength,name,onBlur,onFocus,onPaste, andonKeyDown. That last one is worth flagging — the component already destructured and calledonKeyDown, but only declared it via the wide extension, so narrowing without adding it explicitly would have broken the documented Enter-to-submit escape hatch.Two behavior fixes that fall out of the narrowing
ChatMessagedropped consumer labels. It spread...restbefore its generatedaria-label/aria-labelledby, so<ChatMessage aria-label="…">was silently overridden. The consumer's value now wins and falls back to the generated one.ChatMessageListhardcodedaria-live="polite"with no way to opt out. It's now a documented prop defaulting topolite, so a static transcript can passaria-live="off".Notes
spellCheckwas on my shortlist forChatComposerInputbut the repo'sboolean-prop-namingrule rejects it, and inventing ahasSpellCheckalias for one speculative prop didn't seem worth it. Easy to add if you want it.ChatScrollButton.Tests
12 new tests: passthrough coverage per component, both
ChatSystemMessagevariants (it spreads in two branches), the consumer-label override onChatMessage, thearia-livedefault and override, and the textarea's focus/blur/paste handlers.Full suite passes (3197 tests), lint/typecheck/format clean.
https://claude.ai/code/session_01XFkkvUQfynGRedEYDNxKoY