Skip to content

Only show one tippy at a time #24648

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions web_src/js/modules/tippy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import tippy from 'tippy.js';

const visibleInstances = new Set();

export function createTippy(target, opts = {}) {
const instance = tippy(target, {
appendTo: document.body,
Expand All @@ -9,6 +11,18 @@ export function createTippy(target, opts = {}) {
interactiveBorder: 20,
ignoreAttributes: true,
maxWidth: 500, // increase over default 350px
onHide: (instance) => {
visibleInstances.delete(instance);
},
onDestroy: (instance) => {
visibleInstances.delete(instance);
},
onShow: (instance) => {
for (const visibleInstance of visibleInstances) {
visibleInstance.hide(); // hide other instances
}
visibleInstances.add(instance);
},
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>`,
...(opts?.role && {theme: opts.role}),
...opts,
Expand Down