diff --git a/packages/time-select/__tests__/time-select.spec.ts b/packages/time-select/__tests__/time-select.spec.ts
index 674b1add9d..aafdd84d9d 100644
--- a/packages/time-select/__tests__/time-select.spec.ts
+++ b/packages/time-select/__tests__/time-select.spec.ts
@@ -2,6 +2,7 @@ import { mount } from '@vue/test-utils'
import { nextTick } from 'vue'
import Option from '@element-plus/option'
import TimeSelect from '../src/time-select.vue'
+import { sleep } from '@element-plus/test-utils'
const _mount = (template: string, data, otherObj?) =>
mount(
@@ -48,7 +49,7 @@ describe('TimeSelect', () => {
})
it('set minTime', async () => {
- const wrapper = _mount(``, () => ({}))
+ const wrapper = _mount(``, () => ({}))
const input = wrapper.find('input')
input.trigger('blur')
input.trigger('focus')
@@ -59,7 +60,7 @@ describe('TimeSelect', () => {
})
it('set maxTime', async () => {
- const wrapper = _mount(``, () => ({}))
+ const wrapper = _mount(``, () => ({}))
const input = wrapper.find('input')
input.trigger('blur')
input.trigger('focus')
@@ -107,4 +108,30 @@ describe('TimeSelect', () => {
expect(vm.value).toBe('11:00')
expect(input.element.value).toBe('11:00')
})
+
+ it('ref focus', async () => {
+ _mount(``, () => ({}), {
+ mounted() {
+ this.$refs.input.focus()
+ },
+ })
+ await sleep(50)
+ const popperEl = document.querySelector('.el-select__popper')
+ const attr = popperEl.getAttribute('aria-hidden')
+ expect(attr).toEqual('false')
+ })
+
+ it('ref blur', async () => {
+ _mount(``, () => ({}), {
+ async mounted() {
+ this.$refs.input.focus()
+ await nextTick()
+ this.$refs.input.blur()
+ },
+ })
+ await sleep(50)
+ const popperEl = document.querySelector('.el-select__popper')
+ const attr = popperEl.getAttribute('aria-hidden')
+ expect(attr).toEqual('true')
+ })
})
diff --git a/packages/time-select/src/time-select.vue b/packages/time-select/src/time-select.vue
index 43cf5516b2..810252883c 100644
--- a/packages/time-select/src/time-select.vue
+++ b/packages/time-select/src/time-select.vue
@@ -1,5 +1,6 @@