From 90fe32a3d9be17290044aa45892e36077a3d237c Mon Sep 17 00:00:00 2001 From: Wang Xiao <84308681+waveo-wangxiao@users.noreply.github.com> Date: Thu, 25 Apr 2024 19:29:09 +0800 Subject: [PATCH] Expose Input focus & blur event (#458) --- src/components/vue-tel-input.vue | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/components/vue-tel-input.vue b/src/components/vue-tel-input.vue index 6d716159..0440264b 100644 --- a/src/components/vue-tel-input.vue +++ b/src/components/vue-tel-input.vue @@ -89,7 +89,7 @@ import { parsePhoneNumberFromString } from 'libphonenumber-js'; import { getDefault, setCaretPosition, getCountry, toLowerCase, toUpperCase } from '../utils'; import clickOutside from '../directives/click-outside'; - import { computed, nextTick, onMounted, reactive, shallowRef, watch } from 'vue'; + import { computed, nextTick, onMounted, reactive, shallowRef, watch, defineExpose } from 'vue'; const refRoot = shallowRef() const refList = shallowRef() @@ -557,9 +557,12 @@ function onSpace(e: KeyboardEvent) { emit('space', e); } - // function focus() { - // refInput.value?.focus(); - // } + function focus() { + refInput.value?.focus(); + } + function blur() { + refInput.value?.blur(); + } function toggleDropdown() { if (props.disabled || props.dropdownOptions.disabled) { return; @@ -644,6 +647,10 @@ data.dropdownOpenDirection = 'above'; } } + defineExpose({ + focus, + blur, + })