More fixes for tree and categories interferences

This commit is contained in:
DianaXWiki 2025-11-19 13:36:20 +02:00
parent f1ebaa58e4
commit 4f7b13c54a
2 changed files with 27 additions and 10 deletions

View File

@ -4584,7 +4584,7 @@ define([
config.openFolders = config.openFolders || [];
config.currentPath = config.currentPath || null;
// Check if current path is a subpath of given path (is viewing a child folder)
// Check if current path is a subpath of given path
var isSubpath = function(child, parent) {
if (!child || !parent || child.length <= parent.length) { return false; }
for (var i = 0; i < parent.length; i++) {
@ -4603,9 +4603,12 @@ define([
}
}
}
// Auto-expand parent folders of current path
if (config.currentPath && isSubpath(config.currentPath, path) && path.length < config.currentPath.length) {
return true;
// Auto-expand parent folders of current path, but only when viewing tree
if (config.currentPath && config.rootPath && isSubpath(config.currentPath, path) && path.length < config.currentPath.length) {
if (config.currentPath.length > 0 && config.rootPath.length > 0 &&
config.currentPath[0] === config.rootPath[0]) {
return true;
}
}
return false;
@ -4683,7 +4686,20 @@ define([
}
}
});
if (shouldBeOpened(path) || hasOpenedChild(path)) {
// Auto-expand if explicitly marked as opened
var shouldExpand = shouldBeOpened(path);
// Also expand if has opened children, but only when viewing this tree
if (!shouldExpand && hasOpenedChild(path)) {
// Check if we're currently viewing this tree (same root category)
if (config.currentPath && config.rootPath &&
config.currentPath.length > 0 && config.rootPath.length > 0 &&
config.currentPath[0] === config.rootPath[0]) {
shouldExpand = true;
}
}
if (shouldExpand) {
$element.removeClass('cp-app-drive-element-collapsed');
$collapse.empty().append($expandedIcon.clone());
}

View File

@ -4614,7 +4614,7 @@ define([
newPath.push(key);
var isSharedFolder = manager.isSharedFolder(root[key]) && root[key];
var sfId = manager.isInSharedFolder(newPath) || (isSharedFolder && root[key]);
var folderName = key, $icon, subfolder;
var $icon, isCurrentFolder, subfolder, folderName = key;
if (isSharedFolder) {
var navPath = newPath.slice();
navPath.push(manager.user.userObject.ROOT);
@ -4624,7 +4624,8 @@ define([
// Fix name
var sfData = manager.getSharedFolderData(sfId);
folderName = sfData.title || sfData.lastTitle || Messages.fm_deletedFolder;
var isCurrentFolder = manager.comparePath(navPath, currentPath);
isCurrentFolder = manager.comparePath(navPath, currentPath);
// Fix icon
$icon = isCurrentFolder ? $sharedFolderOpenedIcon : $sharedFolderIcon;
data.content[key] = {
name: folderName,
@ -4636,8 +4637,7 @@ define([
} else {
var isEmpty = manager.isFolderEmpty(root[key]);
subfolder = manager.hasSubfolder(root[key]);
// Check if this is the current folder
var isCurrentFolder = manager.comparePath(newPath, currentPath);
isCurrentFolder = manager.comparePath(newPath, currentPath);
$icon = isEmpty ?
(isCurrentFolder ? $folderOpenedEmptyIcon : $folderEmptyIcon) :
(isCurrentFolder ? $folderOpenedIcon : $folderIcon);
@ -4722,7 +4722,8 @@ define([
},
onFolderExpanded: function (clickedPath, isOpen) {
LS.setFolderOpened(clickedPath, isOpen);
// Also remove all child folders when collapsing a parent
if (clickedPath.length === 1) { return; }
// When collapsing a folder, close all its children
if (!isOpen) {
LS.removeFoldersOpened(clickedPath);
}