mirror of
https://github.com/open-webui/open-webui
synced 2025-05-24 23:04:36 +00:00
Merge pull request #11862 from hurxxxx/feat/auto-edit-new-folder
feat: Automatically enter edit mode when creating a new folder
This commit is contained in:
commit
558295f728
@ -77,6 +77,7 @@
|
|||||||
let allChatsLoaded = false;
|
let allChatsLoaded = false;
|
||||||
|
|
||||||
let folders = {};
|
let folders = {};
|
||||||
|
let newFolderId = null;
|
||||||
|
|
||||||
const initFolders = async () => {
|
const initFolders = async () => {
|
||||||
const folderList = await getFolders(localStorage.token).catch((error) => {
|
const folderList = await getFolders(localStorage.token).catch((error) => {
|
||||||
@ -90,6 +91,11 @@
|
|||||||
for (const folder of folderList) {
|
for (const folder of folderList) {
|
||||||
// Ensure folder is added to folders with its data
|
// Ensure folder is added to folders with its data
|
||||||
folders[folder.id] = { ...(folders[folder.id] || {}), ...folder };
|
folders[folder.id] = { ...(folders[folder.id] || {}), ...folder };
|
||||||
|
|
||||||
|
if (newFolderId && folder.id === newFolderId) {
|
||||||
|
folders[folder.id].isNew = true;
|
||||||
|
newFolderId = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Second pass: Tie child folders to their parents
|
// Second pass: Tie child folders to their parents
|
||||||
@ -150,6 +156,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
|
newFolderId = res.id;
|
||||||
await initFolders();
|
await initFolders();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -215,6 +215,14 @@
|
|||||||
// Event listener for when dragging ends
|
// Event listener for when dragging ends
|
||||||
folderElement.addEventListener('dragend', onDragEnd);
|
folderElement.addEventListener('dragend', onDragEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (folders[folderId].isNew) {
|
||||||
|
folders[folderId].isNew = false;
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
editHandler();
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onDestroy(() => {
|
onDestroy(() => {
|
||||||
@ -301,10 +309,13 @@
|
|||||||
|
|
||||||
await tick();
|
await tick();
|
||||||
|
|
||||||
// focus on the input
|
// focus on the input and select all text
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const input = document.getElementById(`folder-${folderId}-input`);
|
const input = document.getElementById(`folder-${folderId}-input`);
|
||||||
input.focus();
|
if (input) {
|
||||||
|
input.focus();
|
||||||
|
input.select();
|
||||||
|
}
|
||||||
}, 100);
|
}, 100);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user