Skip to content

Commit 1f23466

Browse files
committed
perf(user-combobox): use shallowRef instead deep ref
1 parent b07ba45 commit 1f23466

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

app/components/UserCombobox.vue

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ const emit = defineEmits<{
1515
select: [username: string, isInSuggestions: boolean]
1616
}>()
1717
18-
const inputValue = ref('')
19-
const isOpen = ref(false)
20-
const highlightedIndex = ref(-1)
21-
const inputRef = ref<HTMLInputElement | null>(null)
22-
const listRef = ref<HTMLUListElement | null>(null)
18+
const inputValue = shallowRef('')
19+
const isOpen = shallowRef(false)
20+
const highlightedIndex = shallowRef(-1)
21+
const listRef = useTemplateRef('listRef')
2322
2423
// Generate unique ID for accessibility
2524
const inputId = useId()
@@ -134,18 +133,14 @@ watch(highlightedIndex, index => {
134133
})
135134
136135
// Check for reduced motion preference
137-
const prefersReducedMotion = ref(false)
138-
onMounted(() => {
139-
prefersReducedMotion.value = window.matchMedia('(prefers-reduced-motion: reduce)').matches
140-
})
136+
const prefersReducedMotion = useMediaQuery('(prefers-reduced-motion: reduce)')
141137
</script>
142138

143139
<template>
144140
<div class="relative">
145141
<label v-if="label" :for="inputId" class="sr-only">{{ label }}</label>
146142
<input
147143
:id="inputId"
148-
ref="inputRef"
149144
v-model="inputValue"
150145
type="text"
151146
:placeholder="placeholder ?? 'username…'"

0 commit comments

Comments
 (0)