From fe4261f58fac41b93fbd4141ddd0485934ba0ef6 Mon Sep 17 00:00:00 2001 From: Krishna Ayyalasomayajula Date: Mon, 1 Jun 2026 23:17:51 -0500 Subject: [PATCH] fix: add button override to handle transformerCopyButton onclick string --- mdx-components.tsx | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/mdx-components.tsx b/mdx-components.tsx index b9a5ba7..8eae550 100644 --- a/mdx-components.tsx +++ b/mdx-components.tsx @@ -105,5 +105,28 @@ export function getMDXComponents(components: MDXComponents): MDXComponents { // Collapsible sections details: (props) =>
, summary: (props) => , + + // Buttons (handle onclick string from transformerCopyButton) + button: ({ children, onClick, ...props }: { children?: React.ReactNode; onClick?: string | (() => void); className?: string } & Record) => { + if (typeof onClick === 'string') { + const className = (props.className as string) ?? ''; + return ( + ` + }} + suppressHydrationWarning + /> + ); + } + return ( + + ); + }, } }