Skip to content

fix(v4): forward refs in Button asChild variants#10660

Open
raashish1601 wants to merge 1 commit into
shadcn-ui:mainfrom
raashish1601:fix/8930-button-tooltip-slot-ssr
Open

fix(v4): forward refs in Button asChild variants#10660
raashish1601 wants to merge 1 commit into
shadcn-ui:mainfrom
raashish1601:fix/8930-button-tooltip-slot-ssr

Conversation

@raashish1601
Copy link
Copy Markdown

Summary

Fixes #8930.

  • Convert both v4 registry Button variants to React.forwardRef components.
  • Forward the ref through Slot.Root when asChild is used, preserving composition with Tooltip and other slot-based primitives.
  • Add SSR-focused tests that verify Button asChild renders only the child element and does not wrap it in a nested <button>.

Validation

  • corepack pnpm vitest run apps/v4/registry/new-york-v4/ui/button.test.tsx apps/v4/registry/bases/radix/ui/button.test.tsx
  • corepack pnpm --filter=v4 typecheck
  • corepack pnpm --filter=v4 lint
  • corepack pnpm --filter=v4 validate:registries
  • corepack pnpm --filter=shadcn build
  • git diff --check origin/main...HEAD

Notes

  • corepack pnpm --filter=v4 build could not complete in my local Windows environment because the script invokes bare pnpm and this machine only exposes pnpm through Corepack. Attempting the registry step manually with tsx also fails before this change is exercised because the script expects Bun's JSX runtime and Bun is not installed locally.

Signed-off-by: Raashish Aggarwal <94279692+raashish1601@users.noreply.github.com>
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 15, 2026

@raashish1601 is attempting to deploy a commit to the shadcn-pro Team on Vercel.

A member of the Team first needs to authorize it.

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.

[bug]: Hydration failed in Next.js SSR when using shadcn/ui Button (asChild/Slot?) leading to client re-render

1 participant