展宽保存选择文件夹下拉框
This commit is contained in:
@@ -33,18 +33,27 @@ watch(() => props.modelValue, (newVal) => {
|
|||||||
}, { immediate: true });
|
}, { immediate: true });
|
||||||
|
|
||||||
function expandToId(id: string) {
|
function expandToId(id: string) {
|
||||||
// Find path to this id
|
if (!id) return;
|
||||||
// Since we don't have parent pointers easily available without traversal,
|
|
||||||
// we can rely on the fact that we want to ensure parents are expanded.
|
const findPath = (nodes: any[], targetId: string, path: string[]): string[] | null => {
|
||||||
// A simple way is to traverse the tree.
|
for (const node of nodes) {
|
||||||
// Or, we can just search in flattened list if it had parentId info?
|
if (node.id === targetId) {
|
||||||
// The flattened list in PresetManager has `label` which is path, but maybe not direct parent chain.
|
return path;
|
||||||
// Let's just do a simple tree search if needed.
|
}
|
||||||
|
if (node.children && node.children.length) {
|
||||||
// Actually, let's just rely on user expanding, OR simple search.
|
const found = findPath(node.children, targetId, [...path, node.id]);
|
||||||
// For now, let's not overengineer auto-expansion unless requested.
|
if (found) return found;
|
||||||
// Wait, if I select a deep folder, I expect to see it if I open the dropdown again?
|
}
|
||||||
// Maybe just keep `expandedIds` persistent.
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
const parents = findPath(props.tree, id, []);
|
||||||
|
if (parents && parents.length) {
|
||||||
|
const newSet = new Set(expandedIds.value);
|
||||||
|
parents.forEach(pid => newSet.add(pid));
|
||||||
|
expandedIds.value = newSet;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleDropdown() {
|
function toggleDropdown() {
|
||||||
@@ -182,7 +191,6 @@ onUnmounted(() => {
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
top: calc(100% + 4px);
|
top: calc(100% + 4px);
|
||||||
left: 0;
|
left: 0;
|
||||||
right: 0;
|
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
background-color: var(--color-bg-primary);
|
background-color: var(--color-bg-primary);
|
||||||
border: 1px solid var(--color-border);
|
border: 1px solid var(--color-border);
|
||||||
@@ -190,8 +198,11 @@ onUnmounted(() => {
|
|||||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||||
max-height: 300px;
|
max-height: 300px;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
display: flex;
|
overflow-x: auto;
|
||||||
flex-direction: column;
|
display: block;
|
||||||
|
min-width: 260px;
|
||||||
|
width: max-content;
|
||||||
|
max-width: 400px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.root-option {
|
.root-option {
|
||||||
@@ -202,6 +213,10 @@ onUnmounted(() => {
|
|||||||
border-bottom: 1px solid var(--color-border);
|
border-bottom: 1px solid var(--color-border);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
color: var(--color-text-secondary);
|
color: var(--color-text-secondary);
|
||||||
|
white-space: nowrap;
|
||||||
|
min-width: 100%;
|
||||||
|
width: max-content;
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.root-option:hover {
|
.root-option:hover {
|
||||||
@@ -216,6 +231,9 @@ onUnmounted(() => {
|
|||||||
|
|
||||||
.tree-container {
|
.tree-container {
|
||||||
padding: 0.25rem 0;
|
padding: 0.25rem 0;
|
||||||
|
min-width: 100%;
|
||||||
|
width: max-content;
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-root, .icon-folder {
|
.icon-root, .icon-folder {
|
||||||
|
|||||||
@@ -91,10 +91,16 @@ function handleSelect() {
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 0.5rem 0.75rem;
|
padding: 0.5rem 0.75rem;
|
||||||
|
padding-right: 1rem;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
color: var(--color-text-primary);
|
color: var(--color-text-primary);
|
||||||
transition: background-color 0.1s ease;
|
transition: background-color 0.1s ease;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-name {
|
||||||
|
margin-left: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.item-row:hover {
|
.item-row:hover {
|
||||||
|
|||||||
Reference in New Issue
Block a user