From f16676ca20cf260f2e308ad5ce24991869833226 Mon Sep 17 00:00:00 2001 From: Talent Zeng Date: Fri, 3 Jan 2025 15:27:11 -0500 Subject: [PATCH] fix(openfga): allow nav link in accordion --- src/theme/MDXComponents/Details.tsx | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/theme/MDXComponents/Details.tsx diff --git a/src/theme/MDXComponents/Details.tsx b/src/theme/MDXComponents/Details.tsx new file mode 100644 index 0000000000..4b7aa98f98 --- /dev/null +++ b/src/theme/MDXComponents/Details.tsx @@ -0,0 +1,27 @@ +import React, { type ComponentProps, type ReactElement } from 'react'; +import Details from '@theme/Details'; +import type { Props } from '@theme/MDXComponents/Details'; + +export default function MDXDetails(props: Props): JSX.Element { + const items = React.Children.toArray(props.children); + + const summary = items.find( + (item): item is ReactElement> => React.isValidElement(item) && item.type === 'summary', + ); + + const children = <>{items.filter((item) => item !== summary)}; + + return ( +
{ + if ((e.target as HTMLElement).tagName === 'A' && (e.target as HTMLElement).closest('summary')) { + e.stopPropagation(); + } + }} + summary={summary} + > + {children} +
+ ); +}