-
Notifications
You must be signed in to change notification settings - Fork 4k
Fix empty Markdown code blocks rendering as “undefined” #13074
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
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
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.
Pull Request Overview
This PR fixes an issue where empty Markdown code blocks render as "undefined" instead of being empty. The fix processes the children prop to filter out "undefined" strings and handle null/empty values properly.
Key changes:
- Made the
childrenprop optional in the component interface - Added preprocessing logic to handle various children states (array, null, string, "undefined")
- Simplified the copy button conditional rendering to use the processed text
frontend/lib/src/components/elements/CodeBlock/StreamlitSyntaxHighlighter.tsx
Outdated
Show resolved
Hide resolved
frontend/lib/src/components/elements/CodeBlock/StreamlitSyntaxHighlighter.tsx
Outdated
Show resolved
Hide resolved
frontend/lib/src/components/elements/CodeBlock/StreamlitSyntaxHighlighter.tsx
Outdated
Show resolved
Hide resolved
|
@sfc-gh-bnisco I'm not very good at front-end development. Could you review my PR? |
sfc-gh-bnisco
left a comment
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.
Thank you for the contribution and iterations @ashm-dev! I made some updates and added tests.
frontend/lib/src/components/elements/CodeBlock/StreamlitSyntaxHighlighter.tsx
Show resolved
Hide resolved
sfc-gh-nbellante
left a comment
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.
Only 1 q, other than that LGTM 👍
Fixes #12986