Focus auth username on page load.

This commit is contained in:
DebaucheryLibrarian 2024-03-18 02:03:31 +01:00
parent fe2576c24e
commit 0bd4990b37
2 changed files with 14 additions and 2 deletions

View File

@ -38,6 +38,7 @@
>{{ errorMsg }}</div> >{{ errorMsg }}</div>
<input <input
ref="userInput"
v-model="username" v-model="username"
placeholder="Username or e-mail" placeholder="Username or e-mail"
class="input" class="input"
@ -81,7 +82,7 @@
</template> </template>
<script setup> <script setup>
import { ref, inject } from 'vue'; import { ref, onMounted, inject } from 'vue';
import { post } from '#/src/api.js'; import { post } from '#/src/api.js';
import navigate from '#/src/navigate.js'; import navigate from '#/src/navigate.js';
@ -94,6 +95,7 @@ const username = ref('');
const password = ref(''); const password = ref('');
const errorMsg = ref(null); const errorMsg = ref(null);
const userInput = ref(null);
const showPassword = ref(false); const showPassword = ref(false);
async function login() { async function login() {
@ -111,6 +113,10 @@ async function login() {
errorMsg.value = error.message; errorMsg.value = error.message;
} }
} }
onMounted(() => {
userInput.value.focus();
});
</script> </script>
<style scoped> <style scoped>

View File

@ -39,6 +39,7 @@
>{{ errorMsg }}</div> >{{ errorMsg }}</div>
<input <input
ref="userInput"
v-model="username" v-model="username"
placeholder="Username" placeholder="Username"
class="input" class="input"
@ -122,7 +123,7 @@
</template> </template>
<script setup> <script setup>
import { ref, inject } from 'vue'; import { ref, onMounted, inject } from 'vue';
import { post } from '#/src/api.js'; import { post } from '#/src/api.js';
import navigate from '#/src/navigate.js'; import navigate from '#/src/navigate.js';
@ -136,6 +137,7 @@ const password = ref('');
const passwordConfirm = ref(''); const passwordConfirm = ref('');
const errorMsg = ref(null); const errorMsg = ref(null);
const userInput = ref(null);
const showPassword = ref(false); const showPassword = ref(false);
async function signup() { async function signup() {
@ -159,6 +161,10 @@ async function signup() {
errorMsg.value = error.message; errorMsg.value = error.message;
} }
} }
onMounted(() => {
userInput.value.focus();
});
</script> </script>
<style scoped> <style scoped>