Skip to content

Commit 7be0237

Browse files
authored
Replace direct template ref usage with useTemplateRef helper (#222)
* replace plain template ref usages with useTemplateRef * cleanup unused refs
1 parent 1d7264b commit 7be0237

File tree

4 files changed

+6
-12
lines changed

4 files changed

+6
-12
lines changed

resources/js/components/DeleteUser.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts">
22
import ProfileController from '@/actions/App/Http/Controllers/Settings/ProfileController';
33
import { Form } from '@inertiajs/vue3';
4-
import { ref } from 'vue';
4+
import { useTemplateRef } from 'vue';
55
66
// Components
77
import HeadingSmall from '@/components/HeadingSmall.vue';
@@ -20,7 +20,7 @@ import {
2020
import { Input } from '@/components/ui/input';
2121
import { Label } from '@/components/ui/label';
2222
23-
const passwordInput = ref<InstanceType<typeof Input> | null>(null);
23+
const passwordInput = useTemplateRef('passwordInput');
2424
</script>
2525

2626
<template>

resources/js/components/TwoFactorRecoveryCodes.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import { useTwoFactorAuth } from '@/composables/useTwoFactorAuth';
1212
import { regenerateRecoveryCodes } from '@/routes/two-factor';
1313
import { Form } from '@inertiajs/vue3';
1414
import { Eye, EyeOff, LockKeyhole, RefreshCw } from 'lucide-vue-next';
15-
import { nextTick, onMounted, ref } from 'vue';
15+
import { nextTick, onMounted, ref, useTemplateRef } from 'vue';
1616
1717
const { recoveryCodesList, fetchRecoveryCodes, errors } = useTwoFactorAuth();
1818
const isRecoveryCodesVisible = ref<boolean>(false);
19-
const recoveryCodeSectionRef = ref<HTMLDivElement | null>(null);
19+
const recoveryCodeSectionRef = useTemplateRef('recoveryCodeSectionRef');
2020
2121
const toggleRecoveryCodesVisibility = async () => {
2222
if (!isRecoveryCodesVisible.value && !recoveryCodesList.value.length) {

resources/js/components/TwoFactorSetupModal.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { confirm } from '@/routes/two-factor';
1919
import { Form } from '@inertiajs/vue3';
2020
import { useClipboard } from '@vueuse/core';
2121
import { Check, Copy, Loader2, ScanLine } from 'lucide-vue-next';
22-
import { computed, nextTick, ref, watch } from 'vue';
22+
import { computed, nextTick, ref, useTemplateRef, watch } from 'vue';
2323
2424
interface Props {
2525
requiresConfirmation: boolean;
@@ -37,7 +37,7 @@ const showVerificationStep = ref(false);
3737
const code = ref<number[]>([]);
3838
const codeValue = computed<string>(() => code.value.join(''));
3939
40-
const pinInputContainerRef = ref<HTMLElement | null>(null);
40+
const pinInputContainerRef = useTemplateRef('pinInputContainerRef');
4141
4242
const modalConfig = computed<{
4343
title: string;

resources/js/pages/settings/Password.vue

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import AppLayout from '@/layouts/AppLayout.vue';
55
import SettingsLayout from '@/layouts/settings/Layout.vue';
66
import { edit } from '@/routes/user-password';
77
import { Form, Head } from '@inertiajs/vue3';
8-
import { ref } from 'vue';
98
109
import HeadingSmall from '@/components/HeadingSmall.vue';
1110
import { Button } from '@/components/ui/button';
@@ -19,9 +18,6 @@ const breadcrumbItems: BreadcrumbItem[] = [
1918
href: edit().url,
2019
},
2120
];
22-
23-
const passwordInput = ref<HTMLInputElement | null>(null);
24-
const currentPasswordInput = ref<HTMLInputElement | null>(null);
2521
</script>
2622

2723
<template>
@@ -53,7 +49,6 @@ const currentPasswordInput = ref<HTMLInputElement | null>(null);
5349
<Label for="current_password">Current password</Label>
5450
<Input
5551
id="current_password"
56-
ref="currentPasswordInput"
5752
name="current_password"
5853
type="password"
5954
class="mt-1 block w-full"
@@ -67,7 +62,6 @@ const currentPasswordInput = ref<HTMLInputElement | null>(null);
6762
<Label for="password">New password</Label>
6863
<Input
6964
id="password"
70-
ref="passwordInput"
7165
name="password"
7266
type="password"
7367
class="mt-1 block w-full"

0 commit comments

Comments
 (0)