New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(mdx-loader): properly unwrap mdxAdmonitionTitle placeholder #8246
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,15 +14,21 @@ function extractMDXAdmonitionTitle(children: ReactNode): { | |
rest: ReactNode; | ||
} { | ||
const items = React.Children.toArray(children); | ||
const mdxAdmonitionTitle = items.find( | ||
(item) => | ||
React.isValidElement(item) && | ||
(item.props as {mdxType: string} | null)?.mdxType === | ||
'mdxAdmonitionTitle', | ||
); | ||
const mdxAdmonitionTitle = items.find((item) => { | ||
if (!React.isValidElement(item)) { | ||
return false; | ||
} | ||
const props = item.props as { | ||
mdxType: string; | ||
'data-admonition-title'?: boolean; | ||
} | null; | ||
return ( | ||
props?.mdxType === 'template' && props['data-admonition-title'] === true | ||
); | ||
}) as JSX.Element | undefined; | ||
const rest = <>{items.filter((item) => item !== mdxAdmonitionTitle)}</>; | ||
return { | ||
mdxAdmonitionTitle, | ||
mdxAdmonitionTitle: mdxAdmonitionTitle?.props.children, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey Actually the template trick seems un-necessary: you just found the issue here See prod markup: https://docusaurus.io/tests/pages/markdownPageTests#admonitions The utils code does not unwrap the element and still let it pass through up to the React reconcilier (which emits the warning) Just adding this line fixes the issue There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, great find! Let me try |
||
rest, | ||
}; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears to be a Remark bug that the
template
content does not get serialized 🤔 The rendered output is fine, though. I'm not sure I should change the tag name just to make testing easier.