浏览代码

refac/fix: dynamic height for command options

Timothy Jaeryang Baek 1 月之前
父节点
当前提交
28faaa23c4

+ 3 - 1
src/lib/components/chat/MessageInput/Commands/Knowledge.svelte

@@ -78,7 +78,6 @@
 
 	onMount(async () => {
 		window.addEventListener('resize', adjustHeight);
-		adjustHeight();
 
 		let notes = await getNoteList(localStorage.token).catch(() => {
 			return [];
@@ -175,6 +174,9 @@
 		fuse = new Fuse(items, {
 			keys: ['name', 'description']
 		});
+
+		await tick();
+		adjustHeight();
 	});
 
 	onDestroy(() => {

+ 2 - 1
src/lib/components/chat/MessageInput/Commands/Models.svelte

@@ -76,13 +76,14 @@
 
 	onMount(async () => {
 		window.addEventListener('resize', adjustHeight);
-		adjustHeight();
 
 		await tick();
 		const chatInputElement = document.getElementById('chat-input');
 		await tick();
 		chatInputElement?.focus();
 		await tick();
+
+		adjustHeight();
 	});
 
 	onDestroy(() => {

+ 3 - 1
src/lib/components/chat/MessageInput/Commands/Prompts.svelte

@@ -59,8 +59,10 @@
 		onSelect({ type: 'prompt', data: command });
 	};
 
-	onMount(() => {
+	onMount(async () => {
 		window.addEventListener('resize', adjustHeight);
+
+		await tick();
 		adjustHeight();
 	});