Skip to content

Commit 0afd38b

Browse files
authored
refactor: prefer useTemplateRef (npmx-dev#749)
1 parent 5ab8cf6 commit 0afd38b

4 files changed

Lines changed: 4 additions & 4 deletions

File tree

app/components/AppHeader.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const showMobileMenu = shallowRef(false)
1919
const route = useRoute()
2020
const isMobile = useIsMobile()
2121
const isSearchExpandedManually = shallowRef(false)
22-
const searchBoxRef = shallowRef<{ focus: () => void } | null>(null)
22+
const searchBoxRef = useTemplateRef('searchBoxRef')
2323
2424
// On search page, always show search expanded on mobile
2525
const isOnHomePage = computed(() => route.name === 'index')

app/components/Header/SearchBox.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function handleSearchFocus() {
8080
}
8181
8282
// Expose focus method for parent components
83-
const inputRef = shallowRef<HTMLInputElement | null>(null)
83+
const inputRef = useTemplateRef('inputRef')
8484
function focus() {
8585
inputRef.value?.focus()
8686
}

app/components/Modal.client.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const props = defineProps<{
33
modalTitle: string
44
}>()
55
6-
const dialogRef = ref<HTMLDialogElement>()
6+
const dialogRef = useTemplateRef('dialogRef')
77
88
const modalTitleId = computed(() => {
99
const id = getCurrentInstance()?.attrs.id

app/components/Package/ClaimPackageModal.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ async function handleClaim() {
9696
}
9797
}
9898
99-
const dialogRef = ref<HTMLDialogElement>()
99+
const dialogRef = useTemplateRef('dialogRef')
100100
101101
function open() {
102102
// Reset state and check availability each time modal is opened

0 commit comments

Comments
 (0)