aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js/modules
diff options
context:
space:
mode:
Diffstat (limited to 'web_src/js/modules')
-rw-r--r--web_src/js/modules/tippy.js22
1 files changed, 10 insertions, 12 deletions
diff --git a/web_src/js/modules/tippy.js b/web_src/js/modules/tippy.js
index 3409e1c714..372f7bc8f3 100644
--- a/web_src/js/modules/tippy.js
+++ b/web_src/js/modules/tippy.js
@@ -3,11 +3,9 @@ import tippy from 'tippy.js';
const visibleInstances = new Set();
export function createTippy(target, opts = {}) {
- const {role, content, onHide: optsOnHide, onDestroy: optsOnDestroy, onShow: optOnShow} = opts;
- delete opts.onHide;
- delete opts.onDestroy;
- delete opts.onShow;
-
+ // the callback functions should be destructured from opts,
+ // because we should use our own wrapper functions to handle them, do not let the user override them
+ const {onHide, onShow, onDestroy, ...other} = opts;
const instance = tippy(target, {
appendTo: document.body,
animation: false,
@@ -18,11 +16,11 @@ export function createTippy(target, opts = {}) {
maxWidth: 500, // increase over default 350px
onHide: (instance) => {
visibleInstances.delete(instance);
- return optsOnHide?.(instance);
+ return onHide?.(instance);
},
onDestroy: (instance) => {
visibleInstances.delete(instance);
- return optsOnDestroy?.(instance);
+ return onDestroy?.(instance);
},
onShow: (instance) => {
// hide other tooltip instances so only one tooltip shows at a time
@@ -32,19 +30,19 @@ export function createTippy(target, opts = {}) {
}
}
visibleInstances.add(instance);
- return optOnShow?.(instance);
+ return onShow?.(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>`,
role: 'menu', // HTML role attribute, only tooltips should use "tooltip"
- theme: role || 'menu', // CSS theme, we support either "tooltip" or "menu"
- ...opts,
+ theme: other.role || 'menu', // CSS theme, we support either "tooltip" or "menu"
+ ...other,
});
// for popups where content refers to a DOM element, we use the 'tippy-target' class
// to initially hide the content, now we can remove it as the content has been removed
// from the DOM by tippy
- if (content instanceof Element) {
- content.classList.remove('tippy-target');
+ if (other.content instanceof Element) {
+ other.content.classList.remove('tippy-target');
}
return instance;