Skip to content

Commit 9c388a9

Browse files
committed
clean ".tooltip[data-content]"
1 parent ccac2fe commit 9c388a9

File tree

6 files changed

+11
-22
lines changed

6 files changed

+11
-22
lines changed

templates/repo/issue/view_content/add_reaction.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<div class="header">{{.ctxData.locale.Tr "repo.pick_reaction"}}</div>
88
<div class="divider"></div>
99
{{range $value := AllowedReactions}}
10-
<a class="item reaction" data-tooltip-content="{{$value}}">{{ReactionToEmoji $value}}</a>
10+
<a class="item reaction" data-tooltip-content="{{$value}}" data-reaction-content="{{$value}}">{{ReactionToEmoji $value}}</a>
1111
{{end}}
1212
</div>
1313
</div>

templates/repo/issue/view_content/sidebar.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@
661661
{{if and (not (eq .Issue.PullRequest.HeadRepo.FullName .Issue.PullRequest.BaseRepo.FullName)) .CanWriteToHeadRepo}}
662662
<div class="ui divider"></div>
663663
<div class="inline field">
664-
<div class="ui checkbox tooltip" id="allow-edits-from-maintainers"
664+
<div class="ui checkbox" id="allow-edits-from-maintainers"
665665
data-url="{{.Issue.Link}}"
666666
data-tooltip-content="{{.locale.Tr "repo.pulls.allow_edits_from_maintainers_desc"}}"
667667
data-prompt-error="{{.locale.Tr "repo.pulls.allow_edits_from_maintainers_err"}}"

tests/e2e/utils_e2e.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export async function save_visual(page) {
5353
timeout: 20000,
5454
mask: [
5555
page.locator('.dashboard-navbar span>img.ui.avatar'),
56-
page.locator('.ui.dropdown.jump.item.tooltip span>img.ui.avatar'),
56+
page.locator('.ui.dropdown.jump.item span>img.ui.avatar'),
5757
],
5858
});
5959
}

web_src/js/features/comp/ReactionSelector.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export function initCompReactionSelector(parent) {
2626
url,
2727
data: {
2828
_csrf: csrfToken,
29-
content: $(this).attr('data-reaction-content')
29+
content: $(this).attr('data-reaction-content'),
3030
}
3131
}).done((resp) => {
3232
if (resp && (resp.html || resp.empty)) {

web_src/js/modules/aria/dropdown.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ function attachStaticElements($dropdown, $focusable, $menu) {
102102
});
103103

104104
// use tooltip's content as aria-label if there is no aria-label
105-
if ($dropdown.hasClass('tooltip') && $dropdown.attr('data-content') && !$dropdown.attr('aria-label')) {
106-
$dropdown.attr('aria-label', $dropdown.attr('data-content'));
105+
const tooltipContent = $dropdown.attr('data-tooltip-content');
106+
if (tooltipContent && !$dropdown.attr('aria-label')) {
107+
$dropdown.attr('aria-label', tooltipContent);
107108
}
108109
}
109110

web_src/js/modules/tippy.js

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function createTippy(target, opts = {}) {
3636
* @returns {null|tippy}
3737
*/
3838
function attachTooltip(target, content = null) {
39-
content = content ?? getTooltipContent(target);
39+
content = content ?? target.getAttribute('data-tooltip-content');
4040
if (!content) return null;
4141

4242
const props = {
@@ -67,30 +67,18 @@ function lazyTooltipOnMouseHover(e) {
6767
attachTooltip(this);
6868
}
6969

70-
function getTooltipContent(target) {
71-
// prefer to always use the "[data-tooltip-content]" attribute
72-
// for backward compatibility, we also support the ".tooltip[data-content]" attribute
73-
// in next PR, refactor all the ".tooltip[data-content]" to "[data-tooltip-content]"
74-
let content = target.getAttribute('data-tooltip-content');
75-
if (!content && target.classList.contains('tooltip')) {
76-
content = target.getAttribute('data-content');
77-
}
78-
return content;
79-
}
80-
8170
/**
8271
* Activate the tooltip for all children elements
8372
* And if the element has no aria-label, use the tooltip content as aria-label
8473
* @param target {HTMLElement}
8574
*/
8675
function attachChildrenLazyTooltip(target) {
87-
// the selector must match the logic in getTippyTooltipContent
88-
for (const el of target.querySelectorAll('[data-tooltip-content], .tooltip[data-content]')) {
76+
for (const el of target.querySelectorAll('[data-tooltip-content]')) {
8977
el.addEventListener('mouseover', lazyTooltipOnMouseHover, true);
9078

9179
// meanwhile, if the element has no aria-label, use the tooltip content as aria-label
9280
if (!el.hasAttribute('aria-label')) {
93-
const content = getTooltipContent(el);
81+
const content = target.getAttribute('data-tooltip-content');
9482
if (content) {
9583
el.setAttribute('aria-label', content);
9684
}
@@ -119,7 +107,7 @@ export function initGlobalTooltips() {
119107
observer.observe(document, {
120108
subtree: true,
121109
childList: true,
122-
attributeFilter: ['data-tooltip-content', 'data-content'],
110+
attributeFilter: ['data-tooltip-content'],
123111
});
124112

125113
attachChildrenLazyTooltip(document.documentElement);

0 commit comments

Comments
 (0)