From 51bad93c5c984010a1b5fd7c45816b37b5dcb157 Mon Sep 17 00:00:00 2001 From: HamChowderr Date: Sun, 2 Aug 2026 01:42:19 -0700 Subject: [PATCH] fix(base-ui): HoverCard delay props break the build on a Base UI project MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On a shadcn Base UI project (`init --base base`), `HoverCard` resolves to Base UI's PreviewCard, which has neither `openDelay` nor `closeDelay`. Four elements name those props in a typed position, so `tsc` fails before anything renders: attachments.tsx AttachmentHoverCard 3 errors prompt-input.tsx PromptInputHoverCard 3 errors inline-citation.tsx InlineCitationCard 1 error context.tsx Context 1 error attachments.tsx(375,3): error TS2339: Property 'openDelay' does not exist on type 'Props'. inline-citation.tsx(53,14): error TS2322: Type '{ ...; openDelay: number; }' is not assignable to type 'IntrinsicAttributes & Props'. Reported in #446 for attachments and prompt-input; inline-citation and context have the same defect. Each component now spreads a NO_DELAY object rather than naming the props. Radix keeps the zero-delay behaviour, Base UI ignores the extra keys instead of failing to compile, and a caller's own props still win because they spread last. AttachmentHoverCard and PromptInputHoverCard previously destructured `openDelay = 0, closeDelay = 0` out of props. Their prop type is `ComponentProps`, so on Radix those keys came from HoverCard's own type and callers can still pass them — the defaults are unchanged. On Base UI the keys were never in the type, so nothing that compiled before stops compiling. This does not address the other Base UI failures in #446 — the four `BaseUIEvent<...>` handler-signature errors in prompt-input.tsx are a real typing change and are left alone here. Verified on both bases: `tsc --noEmit` error count in packages/elements is unchanged (56 before, 56 after — all pre-existing, in __tests__), none in these four files, and 950 tests across 46 files pass. --- packages/elements/src/attachments.tsx | 18 ++++++++++++------ packages/elements/src/context.tsx | 12 +++++++++++- packages/elements/src/inline-citation.tsx | 12 +++++++++++- packages/elements/src/prompt-input.tsx | 18 ++++++++++++------ 4 files changed, 46 insertions(+), 14 deletions(-) diff --git a/packages/elements/src/attachments.tsx b/packages/elements/src/attachments.tsx index cc7b2495..a9ce4102 100644 --- a/packages/elements/src/attachments.tsx +++ b/packages/elements/src/attachments.tsx @@ -371,12 +371,18 @@ export const AttachmentRemove = ({ export type AttachmentHoverCardProps = ComponentProps; -export const AttachmentHoverCard = ({ - openDelay = 0, - closeDelay = 0, - ...props -}: AttachmentHoverCardProps) => ( - +// Open/close with no delay. Radix's HoverCard takes these props; Base UI's +// PreviewCard — what `shadcn add` swaps in on a Base UI project — has neither, +// so naming them in a typed position fails to compile there. Spreading keeps the +// behaviour on Radix and is inert on Base UI. A caller's own props still win, +// since they spread last. +const NO_DELAY = { + closeDelay: 0, + openDelay: 0, +} as unknown as ComponentProps; + +export const AttachmentHoverCard = (props: AttachmentHoverCardProps) => ( + ); export type AttachmentHoverCardTriggerProps = ComponentProps< diff --git a/packages/elements/src/context.tsx b/packages/elements/src/context.tsx index 53e28851..7a165e75 100644 --- a/packages/elements/src/context.tsx +++ b/packages/elements/src/context.tsx @@ -42,6 +42,16 @@ const useContextValue = () => { export type ContextProps = ComponentProps & ContextSchema; +// Open/close with no delay. Radix's HoverCard takes these props; Base UI's +// PreviewCard — what `shadcn add` swaps in on a Base UI project — has neither, +// so naming them in a typed position fails to compile there. Spreading keeps the +// behaviour on Radix and is inert on Base UI. A caller's own props still win, +// since they spread last. +const NO_DELAY = { + closeDelay: 0, + openDelay: 0, +} as unknown as ComponentProps; + export const Context = ({ usedTokens, maxTokens, @@ -56,7 +66,7 @@ export const Context = ({ return ( - + ); }; diff --git a/packages/elements/src/inline-citation.tsx b/packages/elements/src/inline-citation.tsx index 171c81cf..a6ec9790 100644 --- a/packages/elements/src/inline-citation.tsx +++ b/packages/elements/src/inline-citation.tsx @@ -49,8 +49,18 @@ export const InlineCitationText = ({ export type InlineCitationCardProps = ComponentProps; +// Open/close with no delay. Radix's HoverCard takes these props; Base UI's +// PreviewCard — what `shadcn add` swaps in on a Base UI project — has neither, +// so naming them in a typed position fails to compile there. Spreading keeps the +// behaviour on Radix and is inert on Base UI. A caller's own props still win, +// since they spread last. +const NO_DELAY = { + closeDelay: 0, + openDelay: 0, +} as unknown as ComponentProps; + export const InlineCitationCard = (props: InlineCitationCardProps) => ( - + ); export type InlineCitationCardTriggerProps = ComponentProps & { diff --git a/packages/elements/src/prompt-input.tsx b/packages/elements/src/prompt-input.tsx index 412c846d..d7b7306d 100644 --- a/packages/elements/src/prompt-input.tsx +++ b/packages/elements/src/prompt-input.tsx @@ -1317,12 +1317,18 @@ export const PromptInputSelectValue = ({ export type PromptInputHoverCardProps = ComponentProps; -export const PromptInputHoverCard = ({ - openDelay = 0, - closeDelay = 0, - ...props -}: PromptInputHoverCardProps) => ( - +// Open/close with no delay. Radix's HoverCard takes these props; Base UI's +// PreviewCard — what `shadcn add` swaps in on a Base UI project — has neither, +// so naming them in a typed position fails to compile there. Spreading keeps the +// behaviour on Radix and is inert on Base UI. A caller's own props still win, +// since they spread last. +const NO_DELAY = { + closeDelay: 0, + openDelay: 0, +} as unknown as ComponentProps; + +export const PromptInputHoverCard = (props: PromptInputHoverCardProps) => ( + ); export type PromptInputHoverCardTriggerProps = ComponentProps<