Skip to content

Commit 3da4766

Browse files
committed
Only show one tippy at a time
1 parent 23ae939 commit 3da4766

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

web_src/js/modules/tippy.js

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import tippy from 'tippy.js';
22

3+
const visibleInstances = new Set();
4+
35
export function createTippy(target, opts = {}) {
46
const instance = tippy(target, {
57
appendTo: document.body,
@@ -9,6 +11,14 @@ export function createTippy(target, opts = {}) {
911
interactiveBorder: 20,
1012
ignoreAttributes: true,
1113
maxWidth: 500, // increase over default 350px
14+
onHide: (instance) => visibleInstances.delete(instance),
15+
onDestroy: (instance) => visibleInstances.delete(instance),
16+
onShow: (instance) => {
17+
for (const visibleInstance of visibleInstances) {
18+
visibleInstance.hide(); // hide other instances
19+
}
20+
visibleInstances.add(instance);
21+
},
1222
arrow: `<svg width="16" height="7"><path d="m0 7 8-7 8 7Z" class="tippy-svg-arrow-outer"/><path d="m0 8 8-7 8 7Z" class="tippy-svg-arrow-inner"/></svg>`,
1323
...(opts?.role && {theme: opts.role}),
1424
...opts,

0 commit comments

Comments
 (0)