Skip to content

Commit 441d2d0

Browse files
committed
fix: adjust textarea height handling and update tab selection order
1 parent 8e4726a commit 441d2d0

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

components/AutoExpandTextArea.vue

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
<script setup lang="ts">
1212
import { useVModel } from '@vueuse/core'
13+
import { nextTick, ref, watch } from 'vue'
1314
1415
const emit = defineEmits<{
1516
(e: 'input', ev: Event): void
@@ -20,18 +21,23 @@ const props = defineProps<{
2021
modelValue?: string
2122
}>()
2223
24+
const textareaRef = ref<HTMLTextAreaElement | null>(null)
2325
const inputValue = useVModel(props, 'modelValue', emit, {
24-
passive: true,
2526
eventName: 'update:modelValue',
2627
})
2728
28-
const onInput = (event: Event) => {
29-
emit('input', event)
30-
const textarea = event.target as HTMLTextAreaElement
29+
watch(inputValue, async () => {
30+
await nextTick()
31+
const textarea = textareaRef.value as HTMLTextAreaElement
32+
if (!textarea) return
3133
textarea.style.height = 'auto' // Reset height to auto to shrink if needed
3234
// force a reflow to ensure the height is recalculated
3335
const _ = textarea.offsetHeight
3436
const scrollHeight = textarea.scrollHeight
3537
textarea.style.height = `${scrollHeight}px` // Set height to scrollHeight to expand
38+
})
39+
40+
const onInput = (event: Event) => {
41+
emit('input', event)
3642
}
3743
</script>

entrypoints/content/components/Chat/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
? 'Ask anything...'
6868
: 'Ask follow up...'
6969
"
70-
class="w-full block outline-none border-none resize-none p-2 field-sizing-content leading-3 text-sm"
70+
class="w-full block outline-none border-none resize-none p-2 field-sizing-content leading-5 text-sm wrap-anywhere"
7171
@keydown="onKeydown"
7272
@compositionstart="isComposing = true"
7373
@compositionend="isComposing = false"

entrypoints/content/components/TabSelector.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ const toggleSelect = (tab: TabInfo) => {
191191
vSelectedTabs.value.splice(index, 1)
192192
}
193193
else {
194-
vSelectedTabs.value.push(tab)
194+
vSelectedTabs.value.unshift(tab)
195195
}
196196
tabStore.contextTabIds.value = vSelectedTabs.value.map((tab) => tab.tabId)
197197
}

0 commit comments

Comments
 (0)