Skip to content

Commit 5544254

Browse files
committed
🤖 Remove overly aggressive mermaid error hiding
The CSS rule [id^="d"][id*="mermaid"] was too broad and hid actual diagrams, not just error messages. The JavaScript cleanup that searched for error messages by selector was also unnecessary. Simplified approach: - Removed CSS rule that hid all mermaid-related elements - Only clean up the specific element with our generated ID - Let mermaid render naturally and show errors via React state This allows diagrams to display in Storybook while still handling errors gracefully through the error state UI. Generated with `cmux`
1 parent 8452c3d commit 5544254

File tree

2 files changed

+1
-14
lines changed

2 files changed

+1
-14
lines changed

src/components/Messages/Mermaid.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,20 +151,12 @@ export const Mermaid: React.FC<{ chart: string }> = ({ chart }) => {
151151
containerRef.current.innerHTML = renderedSvg;
152152
}
153153
} catch (err) {
154-
// Clean up any DOM elements mermaid might have created
154+
// Clean up any DOM elements mermaid might have created with our ID
155155
const errorElement = document.getElementById(id);
156156
if (errorElement) {
157157
errorElement.remove();
158158
}
159159

160-
// Also clean up any error-related elements mermaid might have added to the body
161-
const errorMessages = document.querySelectorAll('[id^="d"][id*="mermaid"]');
162-
errorMessages.forEach((el) => {
163-
if (el.textContent?.includes("Syntax error")) {
164-
el.remove();
165-
}
166-
});
167-
168160
setError(err instanceof Error ? err.message : "Failed to render diagram");
169161
setSvg(""); // Clear any previous SVG
170162
if (containerRef.current) {

src/styles/globals.css

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -614,11 +614,6 @@ code {
614614
max-height: 80vh;
615615
}
616616

617-
/* Hide any mermaid error messages that slip through */
618-
[id^="d"][id*="mermaid"] {
619-
display: none !important;
620-
}
621-
622617
/* Zoom wrapper for mermaid */
623618
.markdown-content .react-transform-wrapper {
624619
position: relative;

0 commit comments

Comments
 (0)