mirror of
https://github.com/open-webui/open-webui
synced 2025-05-24 14:54:33 +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 folders = {};
|
||||
let newFolderId = null;
|
||||
|
||||
const initFolders = async () => {
|
||||
const folderList = await getFolders(localStorage.token).catch((error) => {
|
||||
@ -90,6 +91,11 @@
|
||||
for (const folder of folderList) {
|
||||
// Ensure folder is added to folders with its data
|
||||
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
|
||||
@ -150,6 +156,7 @@
|
||||
});
|
||||
|
||||
if (res) {
|
||||
newFolderId = res.id;
|
||||
await initFolders();
|
||||
}
|
||||
};
|
||||
|
@ -215,6 +215,14 @@
|
||||
// Event listener for when dragging ends
|
||||
folderElement.addEventListener('dragend', onDragEnd);
|
||||
}
|
||||
|
||||
if (folders[folderId].isNew) {
|
||||
folders[folderId].isNew = false;
|
||||
|
||||
setTimeout(() => {
|
||||
editHandler();
|
||||
}, 100);
|
||||
}
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
@ -301,10 +309,13 @@
|
||||
|
||||
await tick();
|
||||
|
||||
// focus on the input
|
||||
// focus on the input and select all text
|
||||
setTimeout(() => {
|
||||
const input = document.getElementById(`folder-${folderId}-input`);
|
||||
input.focus();
|
||||
if (input) {
|
||||
input.focus();
|
||||
input.select();
|
||||
}
|
||||
}, 100);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user