fix: inline rename uses .tree-item-text span instead of direct text node
This commit is contained in:
+8
-11
@@ -843,13 +843,14 @@ const FileOperations = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const textNode = Array.from(item.childNodes).find((node) => node.nodeType === Node.TEXT_NODE && node.textContent.trim());
|
// Find the text span (.tree-item-text) — tree items use spans, not direct text nodes
|
||||||
if (!textNode) {
|
const textSpan = item.querySelector('.tree-item-text');
|
||||||
|
if (!textSpan) {
|
||||||
showToast('Impossible de renommer cet élément', 'error');
|
showToast('Impossible de renommer cet élément', 'error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const originalText = textNode.textContent;
|
const originalText = textSpan.textContent;
|
||||||
const trimmedOriginal = originalText.trim();
|
const trimmedOriginal = originalText.trim();
|
||||||
const currentName = path.split('/').pop() || trimmedOriginal;
|
const currentName = path.split('/').pop() || trimmedOriginal;
|
||||||
const baseName = type === 'file' ? currentName.replace(/(\.[^./\\]+)$/i, '') : currentName;
|
const baseName = type === 'file' ? currentName.replace(/(\.[^./\\]+)$/i, '') : currentName;
|
||||||
@@ -860,17 +861,13 @@ const FileOperations = {
|
|||||||
input.className = 'sidebar-item-input';
|
input.className = 'sidebar-item-input';
|
||||||
input.value = baseName;
|
input.value = baseName;
|
||||||
|
|
||||||
textNode.textContent = ' ';
|
// Hide the text span, show input
|
||||||
const badge = item.querySelector('.badge-small');
|
textSpan.style.display = 'none';
|
||||||
if (badge) {
|
textSpan.insertAdjacentElement('afterend', input);
|
||||||
item.insertBefore(input, badge);
|
|
||||||
} else {
|
|
||||||
item.appendChild(input);
|
|
||||||
}
|
|
||||||
|
|
||||||
const restore = () => {
|
const restore = () => {
|
||||||
input.remove();
|
input.remove();
|
||||||
textNode.textContent = originalText;
|
textSpan.style.display = '';
|
||||||
};
|
};
|
||||||
|
|
||||||
const validateName = (name) => {
|
const validateName = (name) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user