Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang committed Jun 14, 2023
1 parent 58015ba commit cb30446
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
4 changes: 2 additions & 2 deletions web_src/js/features/common-global.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import {svg} from '../svg.js';
import {hideElem, showElem, toggleElem} from '../utils/dom.js';
import {htmlEscape} from 'escape-goat';
import {createTippy} from '../modules/tippy.js';
import {confirmModal} from "./comp/ConfirmModal.js";
import {confirmModal} from './comp/ConfirmModal.js';

const {appUrl, csrfToken, i18n} = window.config;
const {appUrl, csrfToken} = window.config;

export function initGlobalFormDirtyLeaveConfirm() {
// Warn users that try to leave a page after entering data into a form.
Expand Down
2 changes: 1 addition & 1 deletion web_src/js/features/repo-issue-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {updateIssuesMeta} from './repo-issue.js';
import {toggleElem} from '../utils/dom.js';
import {htmlEscape} from 'escape-goat';
import {Sortable} from 'sortablejs';
import {confirmModal} from "./comp/ConfirmModal.js";
import {confirmModal} from './comp/ConfirmModal.js';

function initRepoIssueListCheckboxes() {
const $issueSelectAll = $('.issue-checkbox-all');
Expand Down
20 changes: 8 additions & 12 deletions web_src/js/modules/tippy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ 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;

const {onHide, onShow, onDestroy, ...other} = opts;
const instance = tippy(target, {
appendTo: document.body,
animation: false,
Expand All @@ -18,11 +14,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
Expand All @@ -32,19 +28,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;
Expand Down

0 comments on commit cb30446

Please sign in to comment.