From e22967ada8c0be757491a932152661957208c0c8 Mon Sep 17 00:00:00 2001 From: Bruno Charest Date: Thu, 4 Jun 2026 15:01:05 -0400 Subject: [PATCH] fix: inline rename uses .tree-item-text span instead of direct text node --- frontend/js/ui.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/frontend/js/ui.js b/frontend/js/ui.js index 1330eb9..c6c9df9 100644 --- a/frontend/js/ui.js +++ b/frontend/js/ui.js @@ -843,13 +843,14 @@ const FileOperations = { return; } - const textNode = Array.from(item.childNodes).find((node) => node.nodeType === Node.TEXT_NODE && node.textContent.trim()); - if (!textNode) { + // Find the text span (.tree-item-text) — tree items use spans, not direct text nodes + const textSpan = item.querySelector('.tree-item-text'); + if (!textSpan) { showToast('Impossible de renommer cet élément', 'error'); return; } - const originalText = textNode.textContent; + const originalText = textSpan.textContent; const trimmedOriginal = originalText.trim(); const currentName = path.split('/').pop() || trimmedOriginal; const baseName = type === 'file' ? currentName.replace(/(\.[^./\\]+)$/i, '') : currentName; @@ -860,17 +861,13 @@ const FileOperations = { input.className = 'sidebar-item-input'; input.value = baseName; - textNode.textContent = ' '; - const badge = item.querySelector('.badge-small'); - if (badge) { - item.insertBefore(input, badge); - } else { - item.appendChild(input); - } + // Hide the text span, show input + textSpan.style.display = 'none'; + textSpan.insertAdjacentElement('afterend', input); const restore = () => { input.remove(); - textNode.textContent = originalText; + textSpan.style.display = ''; }; const validateName = (name) => {