diff --git a/chrom-ext/content.js b/chrom-ext/content.js index 64370e3..6f2a67d 100644 --- a/chrom-ext/content.js +++ b/chrom-ext/content.js @@ -66,11 +66,9 @@ // ===== A. CAPTURE TWEET & SELECTED TEXT ===== document.addEventListener('contextmenu', (e) => { - // Lưu text đang bôi đen (cho translate) const sel = window.getSelection().toString().trim(); if (sel) lastSelectedText = sel; - // Lưu tweet text — CHỈ khi click đúng vào article const article = e.target.closest('article'); if (article) { const textEl = @@ -79,7 +77,6 @@ article.querySelector('div[dir="auto"]'); lastTweetText = textEl ? textEl.innerText.trim() : article.innerText.trim().slice(0, 600); } - // ⚠️ KHÔNG xóa lastTweetText nếu không có article (tránh lỗi click vào padding/lề) }); // ===== B. LISTENER ===== @@ -189,6 +186,12 @@ } function openSidebar(tweetText) { + // ⭐ FIX: Nếu mở comment mới (có tweetText), xóa sidebar cũ để render lại từ đầu + if (tweetText && sidebarHost) { + removeSidebar(); + } + + // Nếu sidebar vẫn còn (trường hợp translate hoặc đang mở), chỉ cần mở drawer if (sidebarHost) { const drawer = sidebarHost.shadowRoot.querySelector('.drawer'); if (drawer) drawer.classList.add('open');