навалил фокуса
This commit is contained in:
@@ -48,6 +48,7 @@
|
||||
<!-- </PrimeInputGroupAddon> -->
|
||||
|
||||
<PrimeInputText
|
||||
ref="input"
|
||||
v-model="text"
|
||||
placeholder="Write a message..."
|
||||
fluid
|
||||
@@ -56,13 +57,14 @@
|
||||
@vue:mounted="onInputMounted"
|
||||
/>
|
||||
|
||||
<PrimeButton class="shrink-0" label="Send" severity="contrast" @click="sendMessage" />
|
||||
<PrimeButton class="shrink-0" label="Send" severity="contrast" :disabled="!text" @click="sendMessage" />
|
||||
</PrimeInputGroup>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useEventBus } from '#imports'
|
||||
import { onStartTyping, unrefElement, useEventListener } from '@vueuse/core'
|
||||
import { format } from 'date-fns'
|
||||
import linkifyStr from 'linkify-string'
|
||||
import { useChat } from '~/composables/use-chat'
|
||||
@@ -78,6 +80,7 @@ const eventBus = useEventBus()
|
||||
const { messages } = chat
|
||||
|
||||
const scrollRef = useTemplateRef('scroll')
|
||||
const inputRef = useTemplateRef('input')
|
||||
const contentRef = computed(() => scrollRef.value?.$refs.content)
|
||||
|
||||
const text = ref('')
|
||||
@@ -118,6 +121,14 @@ function onInputMounted(ref: VNode) {
|
||||
ref.el?.focus()
|
||||
}
|
||||
|
||||
useEventListener(window, 'focus', async (evt) => {
|
||||
unrefElement(inputRef.value)?.focus()
|
||||
})
|
||||
|
||||
onStartTyping(() => {
|
||||
unrefElement(inputRef.value)?.focus()
|
||||
})
|
||||
|
||||
const ARRIVED_STATE_THRESHOLD_PIXELS = 1
|
||||
async function onNewMessage() {
|
||||
if (!contentRef.value)
|
||||
|
||||
Reference in New Issue
Block a user