fix: title edit issue

This commit is contained in:
Timothy J. Baek 2024-02-27 22:35:57 -08:00
parent 32361dc3da
commit 5640b38694
1 changed files with 27 additions and 23 deletions

View File

@ -366,13 +366,22 @@
} }
}) as chat, i} }) as chat, i}
<div class=" w-full pr-2 relative"> <div class=" w-full pr-2 relative">
{#if chatTitleEditId === chat.id}
<div
class=" w-full flex justify-between rounded-xl px-3 py-2 hover:bg-gray-900 {chat.id ===
$chatId
? 'bg-gray-900'
: ''} transition whitespace-nowrap text-ellipsis"
>
<input bind:value={chatTitle} class=" bg-transparent w-full outline-none mr-10" />
</div>
{:else}
<a <a
class=" w-full flex justify-between rounded-xl px-3 py-2 hover:bg-gray-900 {chat.id === class=" w-full flex justify-between rounded-xl px-3 py-2 hover:bg-gray-900 {chat.id ===
$chatId $chatId
? 'bg-gray-900' ? 'bg-gray-900'
: ''} transition whitespace-nowrap text-ellipsis" : ''} transition whitespace-nowrap text-ellipsis"
href="/c/{chat.id}" href="/c/{chat.id}"
draggable={isEditing ? 'false' : 'true'}
> >
<div class=" flex self-center flex-1 w-full"> <div class=" flex self-center flex-1 w-full">
<div <div
@ -380,14 +389,11 @@
? 'w-[160px]' ? 'w-[160px]'
: 'w-full'} " : 'w-full'} "
> >
{#if chatTitleEditId === chat.id}
<input bind:value={chatTitle} class=" bg-transparent w-full" />
{:else}
{chat.title} {chat.title}
{/if}
</div> </div>
</div> </div>
</a> </a>
{/if}
{#if chat.id === $chatId} {#if chat.id === $chatId}
<div class=" absolute right-[22px] top-[10px]"> <div class=" absolute right-[22px] top-[10px]">
@ -399,7 +405,6 @@
editChatTitle(chat.id, chatTitle); editChatTitle(chat.id, chatTitle);
chatTitleEditId = null; chatTitleEditId = null;
chatTitle = ''; chatTitle = '';
isEditing = false;
}} }}
> >
<svg <svg
@ -487,7 +492,6 @@
on:click={() => { on:click={() => {
chatTitle = chat.title; chatTitle = chat.title;
chatTitleEditId = chat.id; chatTitleEditId = chat.id;
isEditing = true;
}} }}
> >
<svg <svg