Skip to content

Commit 6d1ba6c

Browse files
committed
fix(CTooltip): tooltip shows up on title update
1 parent 9d64c71 commit 6d1ba6c

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

Diff for: src/directives/CTooltip.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,10 @@ export default {
4848
</div>`
4949
},
5050
update(el, binding, vnode) {
51-
if (binding.value.content !== binding.oldValue.content && el === vnode.elm) {
52-
el._c_tooltip.hide()
51+
if ((binding.value.content !== binding.oldValue.content) && el === vnode.elm) {
5352
vnode.context.$nextTick(() => {
5453
const title = binding.value.content
5554
el._c_tooltip.updateTitleContent(title)
56-
el._c_tooltip.show()
5755
})
5856
}
5957
}

Diff for: src/directives/tests/CTooltip.spec.js

+19-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ const generateWrapper = (config) => {
4646
directives: { CTooltip },
4747
data () {
4848
return {
49-
button: true
49+
button: true,
50+
title: 'tooltip 1'
5051
}
5152
},
5253
mounted () {
@@ -85,6 +86,23 @@ describe(ComponentName, () => {
8586
expect(tooltipWrapper.find('.tooltip-old').isVisible()).toBe(true)
8687
})
8788

89+
it('should update title content', done => {
90+
// todo
91+
const updatedContent = 'Updated tooltip';
92+
const wrapper = tooltipWrapper.find('button')
93+
const instance = wrapper.element._c_tooltip;
94+
expect(
95+
tooltipWrapper.find('.tooltip-old .tooltip-old-inner').element.textContent
96+
).toBe('tooltip');
97+
instance.updateTitleContent(updatedContent);
98+
instance.show();
99+
expect(
100+
tooltipWrapper.find('.tooltip-old .tooltip-old-inner').element.textContent
101+
).toBe(updatedContent);
102+
instance.hide();
103+
done();
104+
});
105+
88106
it('destroys correctly', (done) => {
89107
setTimeout(() => {
90108
expect(tooltipWrapper.find('.btn').exists()).not.toBe(true)

0 commit comments

Comments
 (0)