Repository navigation
Mermaid diagram disappears after blurring from edit mode - #942
Conversation
Preserve mermaidSvg during re-render on blur so the existing diagram stays visible while the async re-render is in-flight. Only clear mermaidSvg on definitive render failure, not when a stale result is discarded. Also clear mermaidError at the start of each new render attempt so stale errors don't linger. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Code Review — PR #942Review Type: Initial Review Code Review SummaryThis is a tightly scoped, single-commit bug fix that correctly addresses the root cause described in issue #938. The change modifies 7 lines of logic in the Mermaid rendering Requirements Check
FindingsNo Critical IssuesThe fix is logically sound. The three behavioral changes introduced are correct and cohesive:
Suggested Improvements
The inline comment on line 135 ( if (svg !== null) {
mermaidSvg = svg;
} else {
// Render returned null (definitive failure) — clear the diagram and show the error.
// Do NOT clear mermaidSvg when the stale guard fires above;
// that would blank the diagram while a subsequent render is still in-flight.
mermaidSvg = null;
mermaidError = 'Diagram rendering failed. Check your Mermaid syntax.';
}This is a nit — the current comments are sufficient for the context. Nitpicks
Testing AssessmentThe issue acceptance criterion "No regression in stale-result protection" is covered implicitly by the unchanged Given this is a bug fix for async UI state that is difficult to unit-test in Happy-DOM without a component harness, the absence of new tests is acceptable. A browser-mode test covering the blur-then-rerender scenario would provide the strongest regression protection here, but is not required to merge. Recommendation: APPROVEThe fix is minimal, correct, and directly addresses all acceptance criteria. The logic is easy to reason about and introduces no new complexity. The comment quality is marginally improvable but not a blocker. |
Comments now explain why each decision is made rather than what it does — the key distinction is between a stale discard (preserve existing diagram, a newer render is in-flight) vs. a definitive failure (no diagram to preserve, render returned null). Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Address Review SummaryAddressed: 1 recommendation ✅ 🟢 Inline comment clarityUpdated comments to explain why rather than what:
⏭️ Testing suggestion (browser-mode test for blur-then-rerender)Deferred — this is async reactive state across a component boundary and would require a non-trivial browser-mode test setup. The fix is a small, well-reasoned logic change with clear correctness; a test would add value but is not required to merge. Re-Review DecisionDecision: NO RE-REVIEW NEEDED Rationale: Only comment text was changed — no logic, no structure, no new risk surface. The previous APPROVE stands. |
* Fix mermaid diagram disappearing after blur from edit mode (closes #938) Preserve mermaidSvg during re-render on blur so the existing diagram stays visible while the async re-render is in-flight. Only clear mermaidSvg on definitive render failure, not when a stale result is discarded. Also clear mermaidError at the start of each new render attempt so stale errors don't linger. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * Address review: improve inline comment clarity Comments now explain why each decision is made rather than what it does — the key distinction is between a stale discard (preserve existing diagram, a newer render is in-flight) vs. a definitive failure (no diagram to preserve, render returned null). Co-Authored-By: Claude Sonnet 4.6 <[email protected]> --------- Co-authored-by: Claude Sonnet 4.6 <[email protected]>
Closes #938