From f44211da8664c6b71b28912ccb671f3ee7ea7df9 Mon Sep 17 00:00:00 2001 From: kooriookami <38392315+kooriookami@users.noreply.github.com> Date: Sat, 10 Jul 2021 20:46:51 +0800 Subject: [PATCH] fix(time-select): fix missing blur method (#2477) fix #1925 --- .../time-select/__tests__/time-select.spec.ts | 31 +++++++++++++++++-- packages/time-select/src/time-select.vue | 17 ++++++++-- website/docs/en-US/time-select.md | 6 ++-- website/docs/es/time-select.md | 2 +- website/docs/fr-FR/time-select.md | 6 ++-- website/docs/jp/time-select.md | 6 ++-- website/docs/zh-CN/time-select.md | 4 +-- 7 files changed, 56 insertions(+), 16 deletions(-) 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 @@