fix(components): [dropdown] ignore show/hide timeouts for click trigger (#6720)

This commit is contained in:
Delyan Haralanov 2022-03-21 15:52:58 +02:00 committed by GitHub
parent e4c6f6d0d9
commit b61dc63375
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 2 deletions

View File

@ -568,4 +568,50 @@ describe('Dropdown', () => {
.classes()
).toContain('is-disabled')
})
test('set show-timeout/hide-timeout when trigger is hover', async () => {
const wrapper = _mount(
`
<el-dropdown trigger="hover" :show-timeout="200" :hide-timeout="300">
<span class="el-dropdown-link">
Dropdown List
</span>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item>Item</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
`,
() => ({})
)
const tooltipElement = wrapper.getComponent({
name: 'ElTooltip',
})
expect(tooltipElement.vm.showAfter).toBe(200)
expect(tooltipElement.vm.hideAfter).toBe(300)
})
test('ignore show-timeout/hide-timeout when trigger is not hover', async () => {
const wrapper = _mount(
`
<el-dropdown trigger="click" :show-timeout="200" :hide-timeout="300">
<span class="el-dropdown-link">
Dropdown List
</span>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item>Item</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
`,
() => ({})
)
const tooltipElement = wrapper.getComponent({
name: 'ElTooltip',
})
expect(tooltipElement.vm.showAfter).toBe(0)
expect(tooltipElement.vm.hideAfter).toBe(0)
})
})

View File

@ -6,13 +6,13 @@
:fallback-placements="['bottom', 'top']"
:popper-options="popperOptions"
:gpu-acceleration="false"
:hide-after="hideTimeout"
:hide-after="trigger === 'hover' ? hideTimeout : 0"
:manual-mode="true"
:placement="placement"
:popper-class="[ns.e('popper'), popperClass]"
:reference-element="referenceElementRef?.$el"
:trigger="trigger"
:show-after="showTimeout"
:show-after="trigger === 'hover' ? showTimeout : 0"
:stop-popper-mouse-event="false"
:virtual-ref="triggeringElementRef"
:virtual-triggering="splitButton"