Sfoglia il codice sorgente

Merge pull request #11830 from hurxxxx/feat/chat-title-rename-enter-submit

feat: submit chat title rename with Enter, cancel with ESC
Timothy Jaeryang Baek 3 mesi fa
parent
commit
1813bb509b
1 ha cambiato i file con 14 aggiunte e 0 eliminazioni
  1. 14 0
      src/lib/components/layout/Sidebar/ChatItem.svelte

+ 14 - 0
src/lib/components/layout/Sidebar/ChatItem.svelte

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