feat: submit chat title rename with Enter, cancel with ESC

This commit is contained in:
hurxxxx 2025-03-19 02:00:58 +09:00
parent b03fc97e28
commit 3b624f35ac

View File

@ -198,6 +198,19 @@
}); });
let showDeleteConfirm = false; let showDeleteConfirm = false;
const keyDownEvent = (e) => {
if (e.key === 'Enter') {
e.preventDefault();
editChatTitle(id, chatTitle);
confirmEdit = false;
chatTitle = '';
} else if (e.key === 'Escape') {
e.preventDefault();
confirmEdit = false;
chatTitle = '';
}
};
</script> </script>
<ShareChatModal bind:show={showShareChatModal} chatId={id} /> <ShareChatModal bind:show={showShareChatModal} chatId={id} />
@ -246,6 +259,7 @@
bind:value={chatTitle} bind:value={chatTitle}
id="chat-title-input-{id}" id="chat-title-input-{id}"
class=" bg-transparent w-full outline-hidden mr-10" class=" bg-transparent w-full outline-hidden mr-10"
on:keydown={keyDownEvent}
/> />
</div> </div>
{:else} {:else}