From a1c5057fe81c25dfd1777e9625eb5480c45897ea Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Mon, 19 Jun 2023 15:46:50 +0800 Subject: Batch delete issue and improve tippy opts (#25253) 1. Add "batch delete" button for selected issues, close #22273 2. Address the review in https://github.com/go-gitea/gitea/pull/25219#discussion_r1229266083 --- web_src/js/modules/tippy.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'web_src/js/modules') 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: ``, 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; -- cgit v1.2.3