mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-02 03:08:21 +08:00
fix(components): [select] with teleported="false" dropdown closes abnormally (#17548)
* fix(components): with teleported=false dropdown closes abnormally * fix: test error * fix: test error --------- Co-authored-by: btea <2356281422@qq.com> Co-authored-by: qiang <qw13131wang@gmail.com>
This commit is contained in:
parent
96a081b755
commit
50ba6c2c77
@ -323,8 +323,9 @@ describe('Select', () => {
|
|||||||
DEFAULT_PLACEHOLDER
|
DEFAULT_PLACEHOLDER
|
||||||
)
|
)
|
||||||
const select = wrapper.findComponent({ name: 'ElSelect' })
|
const select = wrapper.findComponent({ name: 'ElSelect' })
|
||||||
await select.trigger('mouseenter')
|
const trigger = wrapper.find(`.${WRAPPER_CLASS_NAME}`)
|
||||||
await select.trigger('click')
|
await trigger.trigger('mouseenter')
|
||||||
|
await trigger.trigger('click')
|
||||||
await nextTick()
|
await nextTick()
|
||||||
expect((select.vm as any).expanded).toBe(true)
|
expect((select.vm as any).expanded).toBe(true)
|
||||||
})
|
})
|
||||||
@ -1592,8 +1593,9 @@ describe('Select', () => {
|
|||||||
() => ({ value: 'test' })
|
() => ({ value: 'test' })
|
||||||
)
|
)
|
||||||
const vm = wrapper.vm as any
|
const vm = wrapper.vm as any
|
||||||
await wrapper.trigger('mouseenter')
|
const trigger = wrapper.find(`.${WRAPPER_CLASS_NAME}`)
|
||||||
await wrapper.trigger('click')
|
await trigger.trigger('mouseenter')
|
||||||
|
await trigger.trigger('click')
|
||||||
const selectVm = wrapper.findComponent({ name: 'ElSelect' }).vm as any
|
const selectVm = wrapper.findComponent({ name: 'ElSelect' }).vm as any
|
||||||
expect(selectVm.expanded).toBe(true)
|
expect(selectVm.expanded).toBe(true)
|
||||||
expect(wrapper.find(`.${PLACEHOLDER_CLASS_NAME}`).text()).toBe('test')
|
expect(wrapper.find(`.${PLACEHOLDER_CLASS_NAME}`).text()).toBe('test')
|
||||||
@ -1673,9 +1675,9 @@ describe('Select', () => {
|
|||||||
value: 'test',
|
value: 'test',
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
const select = wrapper.findComponent({ name: 'ElSelect' })
|
const trigger = wrapper.find(`.${WRAPPER_CLASS_NAME}`)
|
||||||
await select.trigger('mouseenter')
|
await trigger.trigger('mouseenter')
|
||||||
await select.trigger('click')
|
await trigger.trigger('click')
|
||||||
await nextTick()
|
await nextTick()
|
||||||
expect(
|
expect(
|
||||||
!!(document.querySelector('.el-select__popper') as HTMLElement).style
|
!!(document.querySelector('.el-select__popper') as HTMLElement).style
|
||||||
@ -2196,9 +2198,10 @@ describe('Select', () => {
|
|||||||
clearable: true,
|
clearable: true,
|
||||||
})
|
})
|
||||||
const select = wrapper.findComponent({ name: 'ElSelect' })
|
const select = wrapper.findComponent({ name: 'ElSelect' })
|
||||||
await select.trigger('click')
|
const trigger = wrapper.find(`.${WRAPPER_CLASS_NAME}`)
|
||||||
|
await trigger.trigger('click')
|
||||||
expect((select.vm as any).expanded).toBe(true)
|
expect((select.vm as any).expanded).toBe(true)
|
||||||
await select.trigger('click')
|
await trigger.trigger('click')
|
||||||
expect((select.vm as any).expanded).toBe(false)
|
expect((select.vm as any).expanded).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -2208,11 +2211,11 @@ describe('Select', () => {
|
|||||||
clearable: true,
|
clearable: true,
|
||||||
})
|
})
|
||||||
const select = wrapper.findComponent({ name: 'ElSelect' })
|
const select = wrapper.findComponent({ name: 'ElSelect' })
|
||||||
|
const trigger = wrapper.find(`.${WRAPPER_CLASS_NAME}`)
|
||||||
await select.trigger('click')
|
await trigger.trigger('click')
|
||||||
expect((select.vm as any).expanded).toBe(true)
|
expect((select.vm as any).expanded).toBe(true)
|
||||||
|
|
||||||
await select.trigger('click')
|
await trigger.trigger('click')
|
||||||
expect((select.vm as any).expanded).toBe(false)
|
expect((select.vm as any).expanded).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
:class="[nsSelect.b(), nsSelect.m(selectSize)]"
|
:class="[nsSelect.b(), nsSelect.m(selectSize)]"
|
||||||
@[mouseEnterEventName]="states.inputHovering = true"
|
@[mouseEnterEventName]="states.inputHovering = true"
|
||||||
@mouseleave="states.inputHovering = false"
|
@mouseleave="states.inputHovering = false"
|
||||||
@click.prevent.stop="toggleMenu"
|
|
||||||
>
|
>
|
||||||
<el-tooltip
|
<el-tooltip
|
||||||
ref="tooltipRef"
|
ref="tooltipRef"
|
||||||
@ -35,6 +34,7 @@
|
|||||||
nsSelect.is('filterable', filterable),
|
nsSelect.is('filterable', filterable),
|
||||||
nsSelect.is('disabled', selectDisabled),
|
nsSelect.is('disabled', selectDisabled),
|
||||||
]"
|
]"
|
||||||
|
@click.prevent.stop="toggleMenu"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
v-if="$slots.prefix"
|
v-if="$slots.prefix"
|
||||||
|
@ -14,6 +14,7 @@ afterEach(() => {
|
|||||||
document.documentElement.innerHTML = ''
|
document.documentElement.innerHTML = ''
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const WRAPPER_CLASS_NAME = 'el-select__wrapper'
|
||||||
const PLACEHOLDER_CLASS_NAME = 'el-select__placeholder'
|
const PLACEHOLDER_CLASS_NAME = 'el-select__placeholder'
|
||||||
|
|
||||||
describe('TimeSelect', () => {
|
describe('TimeSelect', () => {
|
||||||
@ -137,7 +138,8 @@ describe('TimeSelect', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
wrapper.findComponent(TimeSelect).vm.$.exposed!.focus()
|
wrapper.findComponent(TimeSelect).vm.$.exposed!.focus()
|
||||||
await wrapper.findComponent(TimeSelect).trigger('click')
|
const trigger = wrapper.find(`.${WRAPPER_CLASS_NAME}`)
|
||||||
|
await trigger.trigger('click')
|
||||||
|
|
||||||
await nextTick()
|
await nextTick()
|
||||||
await nextTick()
|
await nextTick()
|
||||||
|
Loading…
Reference in New Issue
Block a user