refactor: use autofocus parameter

Using the `ref` seems to be broken but using the autofocus parameter
seems to fix it.
This commit is contained in:
Johann150 2022-07-06 18:23:05 +02:00
parent 41bef75d1a
commit ac6b8f3480
No known key found for this signature in database
GPG Key ID: 9EE6577A2A06F8F1
1 changed files with 1 additions and 14 deletions

View File

@ -11,7 +11,7 @@
<div class="tbhwbxda">
<div class="form">
<FormSplit :min-width="170">
<MkInput ref="usernameEl" v-model="username" @update:modelValue="search">
<MkInput v-model="username" :autofocus="true" @update:modelValue="search">
<template #label>{{ $ts.username }}</template>
<template #prefix>@</template>
</MkInput>
@ -70,15 +70,8 @@ let host = $ref('');
let users: misskey.entities.UserDetailed[] = $ref([]);
let recentUsers: misskey.entities.UserDetailed[] = $ref([]);
let selected: misskey.entities.UserDetailed | null = $ref(null);
let usernameEl: HTMLElement = $ref();
let dialogEl = $ref();
const focus = () => {
if (usernameEl) {
usernameEl.focus();
}
};
const search = () => {
if (username === '' && host === '') {
users = [];
@ -112,12 +105,6 @@ const cancel = () => {
};
onMounted(() => {
focus();
nextTick(() => {
focus();
});
os.api('users/show', {
userIds: defaultStore.state.recentlyUsedUsers,
}).then(users => {