From 9855603d6e50e78910b8bf579e5da0e4dedc16ce Mon Sep 17 00:00:00 2001 From: tegwick Date: Tue, 4 Nov 2025 09:25:15 +0100 Subject: [PATCH] fix: enable section click functionality for edit UI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fixed conflicting DOMContentLoaded handlers that were overwriting section content - Added modular component detection to prevent content rendering conflicts - Updated initialization to use markdown content directly instead of empty container - Verified complete functionality: sections clickable, floating menu appears, accept/cancel buttons work Root cause: Two competing event handlers were initializing content differently, causing sections to be overwritten by direct HTML rendering. Solution: Added component detection guard and proper content initialization. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- markitect/clean_document_manager.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/markitect/clean_document_manager.py b/markitect/clean_document_manager.py index d5e1e23b..d3d3cd72 100644 --- a/markitect/clean_document_manager.py +++ b/markitect/clean_document_manager.py @@ -1104,9 +1104,16 @@ class CleanDocumentManager: document.addEventListener('DOMContentLoaded', function() {{ console.log("Rendering content..."); + // Check if modular components are being used + if (typeof SectionManager !== 'undefined') {{ + console.log("✓ Modular components detected - skipping direct content rendering"); + console.log("✓ Content will be rendered by modular architecture"); + return; + }} + const contentDiv = document.getElementById('markdown-content'); - // Step 1: Ensure content is always displayed + // Step 1: Ensure content is always displayed (fallback for non-modular mode) if (contentDiv) {{ if (typeof marked !== 'undefined') {{ try {{ @@ -1259,11 +1266,14 @@ document.addEventListener('DOMContentLoaded', function() { debugPanel.addMessage(`Changes cancelled for section: ${data.sectionId}`, 'WARNING'); }); - // Initialize with existing markdown content if present - const existingContent = container.textContent || container.innerText || ''; - if (existingContent.trim()) { - const sections = sectionManager.createSectionsFromMarkdown(existingContent); + // Initialize with markdown content + const markdownToRender = markdownContent || ''; + if (markdownToRender.trim()) { + const sections = sectionManager.createSectionsFromMarkdown(markdownToRender); domRenderer.renderAllSections(sections); + debugPanel.addMessage(`Initialized with ${sections.length} sections`, 'INFO'); + } else { + debugPanel.addMessage('No markdown content to initialize', 'WARNING'); } // Make components globally available for debugging