Add exposed focus function to TextInput component
authorAdam Dullage <redacted>
Sat, 4 May 2024 10:52:30 +0000 (11:52 +0100)
committerAdam Dullage <redacted>
Sat, 4 May 2024 10:52:30 +0000 (11:52 +0100)
client/components/TextInput.vue

index 204f631b24a7c83d2eb24ac32d35f5d689309388..4f93c3ed015cb3a9c6716e678149f2175e169ad0 100644 (file)
@@ -4,9 +4,19 @@
     class="w-full rounded border border-theme-border bg-theme-background-elevated px-3 py-2 focus:outline-none focus:ring-1"
     placeholder="Search"
     v-model="model"
+    ref="input"
   />
 </template>
 
 <script setup>
-const model = defineModel()
+import { ref } from "vue";
+
+const model = defineModel();
+const input = ref();
+
+function focus() {
+  input.value.focus();
+}
+
+defineExpose({ focus });
 </script>
git clone https://git.99rst.org/PROJECT