Skip to content

Commit 56bc9d2

Browse files
committed
fix: createTooltip().show()
1 parent c5f50e0 commit 56bc9d2

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

packages/demo-vue3/src/router.js

+7
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ export const demos = [
3737
label: 'Directive manual',
3838
},
3939
},
40+
{
41+
path: '/directive/create-tooltip',
42+
component: () => import('./views/directive/CreateTooltip.vue'),
43+
meta: {
44+
label: 'createTooltip',
45+
},
46+
},
4047
{
4148
path: '/component/demo1',
4249
component: () => import('./views/component/DropdownDemo1.vue'),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<script setup>
2+
import { createTooltip, destroyTooltip } from 'floating-vue'
3+
4+
function clipboardSuccess (el) {
5+
el.classList.add('copied')
6+
const tooltip = createTooltip(el, {
7+
triggers: [],
8+
content: 'Copied!',
9+
delay: 0,
10+
})
11+
tooltip.show()
12+
setTimeout(() => {
13+
el.classList.remove('copied')
14+
tooltip.hide()
15+
// Transition
16+
setTimeout(() => {
17+
destroyTooltip(el)
18+
}, 400)
19+
}, 600)
20+
}
21+
</script>
22+
23+
<template>
24+
<div>
25+
<button
26+
class="px-4 py-2 bg-green-100 rounded"
27+
@click="clipboardSuccess($event.currentTarget)"
28+
>
29+
Copy
30+
</button>
31+
</div>
32+
</template>

packages/floating-vue/src/directives/v-tooltip.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function ensureDirectiveApp () {
6565
return this.directives.map((directive) => {
6666
return h(TooltipDirective, {
6767
...directive.options,
68-
shown: directive.shown.value || directive.options.shown,
68+
shown: directive.shown || directive.options.shown,
6969
key: directive.id,
7070
})
7171
})
@@ -126,7 +126,7 @@ export function destroyTooltip (el) {
126126
}
127127
}
128128

129-
export function bind (el, { value, oldValue, modifiers }) {
129+
export function bind (el, { value, modifiers }) {
130130
const options = getOptions(el, value, modifiers)
131131
if (!options.content || getDefaultConfig(options.theme || 'tooltip', 'disabled')) {
132132
destroyTooltip(el)

0 commit comments

Comments
 (0)