mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-14 05:15:18 +00:00
refac: folder click behaviour
This commit is contained in:
parent
49c9b3199f
commit
19e3214997
2 changed files with 35 additions and 24 deletions
|
|
@ -401,11 +401,8 @@
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
dispatch('select');
|
dispatch('select');
|
||||||
|
|
||||||
if (
|
if ($selectedFolder) {
|
||||||
$selectedFolder &&
|
selectedFolder.set(null);
|
||||||
!($selectedFolder?.items?.chats.map((chat) => chat.id) ?? []).includes(id)
|
|
||||||
) {
|
|
||||||
selectedFolder.set(null); // Reset selected folder if the chat is not in it
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($mobile) {
|
if ($mobile) {
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,8 @@
|
||||||
let draggedOver = false;
|
let draggedOver = false;
|
||||||
let dragged = false;
|
let dragged = false;
|
||||||
|
|
||||||
|
let clickTimer = null;
|
||||||
|
|
||||||
let name = '';
|
let name = '';
|
||||||
|
|
||||||
const onDragOver = (e) => {
|
const onDragOver = (e) => {
|
||||||
|
|
@ -342,14 +344,15 @@
|
||||||
console.log('Edit');
|
console.log('Edit');
|
||||||
await tick();
|
await tick();
|
||||||
name = folders[folderId].name;
|
name = folders[folderId].name;
|
||||||
|
|
||||||
edit = true;
|
edit = true;
|
||||||
|
|
||||||
|
await tick();
|
||||||
await tick();
|
await tick();
|
||||||
|
|
||||||
const input = document.getElementById(`folder-${folderId}-input`);
|
const input = document.getElementById(`folder-${folderId}-input`);
|
||||||
|
|
||||||
if (input) {
|
if (input) {
|
||||||
input.focus();
|
input.focus();
|
||||||
|
input.select();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -427,27 +430,44 @@
|
||||||
<div class="w-full group">
|
<div class="w-full group">
|
||||||
<button
|
<button
|
||||||
id="folder-{folderId}-button"
|
id="folder-{folderId}-button"
|
||||||
class="relative w-full py-1.5 px-2 rounded-lg flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-500 font-medium hover:bg-gray-100 dark:hover:bg-gray-900 transition {$selectedFolder?.id ===
|
class="relative w-full py-1 px-1.5 rounded-lg flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-500 font-medium hover:bg-gray-100 dark:hover:bg-gray-900 transition {$selectedFolder?.id ===
|
||||||
folderId
|
folderId
|
||||||
? 'bg-gray-100 dark:bg-gray-900'
|
? 'bg-gray-100 dark:bg-gray-900'
|
||||||
: ''}"
|
: ''}"
|
||||||
on:dblclick={() => {
|
on:dblclick={(e) => {
|
||||||
|
if (clickTimer) {
|
||||||
|
clearTimeout(clickTimer); // cancel the single-click action
|
||||||
|
clickTimer = null;
|
||||||
|
}
|
||||||
renameHandler();
|
renameHandler();
|
||||||
}}
|
}}
|
||||||
on:click={async (e) => {
|
on:click={async (e) => {
|
||||||
await goto('/');
|
(e) => e.stopPropagation();
|
||||||
|
if (clickTimer) {
|
||||||
selectedFolder.set(folders[folderId]);
|
clearTimeout(clickTimer);
|
||||||
|
clickTimer = null;
|
||||||
if ($mobile) {
|
|
||||||
showSidebar.set(!$showSidebar);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clickTimer = setTimeout(async () => {
|
||||||
|
await goto('/');
|
||||||
|
|
||||||
|
selectedFolder.set(folders[folderId]);
|
||||||
|
|
||||||
|
if ($mobile) {
|
||||||
|
showSidebar.set(!$showSidebar);
|
||||||
|
}
|
||||||
|
clickTimer = null;
|
||||||
|
}, 100); // 100ms delay (typical double-click threshold)
|
||||||
|
}}
|
||||||
|
on:pointerup={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="text-gray-300 dark:text-gray-600 transition-all"
|
class="text-gray-300 dark:text-gray-600 transition-all p-[3px] dark:hover:bg-gray-850 rounded-lg"
|
||||||
on:click={(e) => {
|
on:click={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
open = !open;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{#if folders[folderId]?.meta?.icon}
|
{#if folders[folderId]?.meta?.icon}
|
||||||
|
|
@ -479,10 +499,8 @@
|
||||||
id="folder-{folderId}-input"
|
id="folder-{folderId}-input"
|
||||||
type="text"
|
type="text"
|
||||||
bind:value={name}
|
bind:value={name}
|
||||||
on:focus={(e) => {
|
|
||||||
e.target.select();
|
|
||||||
}}
|
|
||||||
on:blur={() => {
|
on:blur={() => {
|
||||||
|
console.log('Blur');
|
||||||
updateHandler({ name });
|
updateHandler({ name });
|
||||||
edit = false;
|
edit = false;
|
||||||
}}
|
}}
|
||||||
|
|
@ -509,10 +527,6 @@
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class="absolute z-10 right-2 invisible group-hover:visible self-center flex items-center dark:text-gray-300"
|
class="absolute z-10 right-2 invisible group-hover:visible self-center flex items-center dark:text-gray-300"
|
||||||
on:pointerup={(e) => {
|
|
||||||
e.stopPropagation();
|
|
||||||
}}
|
|
||||||
on:click={(e) => e.stopPropagation()}
|
|
||||||
>
|
>
|
||||||
<FolderMenu
|
<FolderMenu
|
||||||
onEdit={() => {
|
onEdit={() => {
|
||||||
|
|
@ -525,7 +539,7 @@
|
||||||
exportHandler();
|
exportHandler();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<button class="p-0.5 dark:hover:bg-gray-850 rounded-lg touch-auto" on:click={(e) => {}}>
|
<button class="p-1 dark:hover:bg-gray-850 rounded-lg touch-auto" on:click={(e) => {}}>
|
||||||
<EllipsisHorizontal className="size-4" strokeWidth="2.5" />
|
<EllipsisHorizontal className="size-4" strokeWidth="2.5" />
|
||||||
</button>
|
</button>
|
||||||
</FolderMenu>
|
</FolderMenu>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue