mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
fix(components): [tooltip] sync visible after disabled toggle (#23738)
This commit is contained in:
@@ -236,5 +236,31 @@ describe('<ElTooltip />', () => {
|
||||
expect(document.activeElement).not.toBe(triggerEl.element)
|
||||
expect(wrapper.emitted()).toHaveProperty('show')
|
||||
})
|
||||
|
||||
it('should resync visibility when disabled toggles in controlled mode', async () => {
|
||||
wrapper = createComponent(
|
||||
{
|
||||
visible: true,
|
||||
disabled: true,
|
||||
},
|
||||
content
|
||||
)
|
||||
await nextTick()
|
||||
await rAF()
|
||||
|
||||
expect(wrapper.emitted()).not.toHaveProperty('show')
|
||||
|
||||
await wrapper.setProps({ disabled: false })
|
||||
await nextTick()
|
||||
await rAF()
|
||||
|
||||
expect(wrapper.emitted()).toHaveProperty('show')
|
||||
|
||||
await wrapper.setProps({ disabled: true })
|
||||
await nextTick()
|
||||
await rAF()
|
||||
|
||||
expect(wrapper.emitted()).toHaveProperty('hide')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -171,6 +171,9 @@ watch(
|
||||
if (disabled && open.value) {
|
||||
open.value = false
|
||||
}
|
||||
if (!disabled && isBoolean(props.visible)) {
|
||||
open.value = props.visible
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user