fix(components): [tooltip] sync visible after disabled toggle (#23738)

This commit is contained in:
snowbitx
2026-03-09 21:36:25 +08:00
committed by GitHub
parent 8de357ca9a
commit 0b9556240b
2 changed files with 29 additions and 0 deletions

View File

@@ -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')
})
})
})

View File

@@ -171,6 +171,9 @@ watch(
if (disabled && open.value) {
open.value = false
}
if (!disabled && isBoolean(props.visible)) {
open.value = props.visible
}
}
)