Skip to content

Commit cd7bd85

Browse files
wxiaoguanglunny
andauthored
Fix incorrect display for comment context menu (#23343) (#23344)
Backport #23343 Fix a regression of #23014: the `a` couldn't be used here because Fomantic UI has style conflicts: `.ui.comments .comment .actions a { display: inline-block; }` Co-authored-by: Lunny Xiao <[email protected]>
1 parent cf80f82 commit cd7bd85

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

templates/repo/issue/view_content/context_menu.tmpl

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
{{else}}
1111
{{$referenceUrl = Printf "%s/files#%s" .ctx.Issue.Link .item.HashTag}}
1212
{{end}}
13-
<a class="item context" data-clipboard-text-type="url" data-clipboard-text="{{AppSubUrl}}{{$referenceUrl}}">{{.ctx.locale.Tr "repo.issues.context.copy_link"}}</a>
14-
<a class="item context quote-reply {{if .diff}}quote-reply-diff{{end}}" data-target="{{.item.HashTag}}-raw">{{.ctx.locale.Tr "repo.issues.context.quote_reply"}}</a>
13+
<div class="item context js-aria-clickable" data-clipboard-text-type="url" data-clipboard-text="{{AppSubUrl}}{{$referenceUrl}}">{{.ctx.locale.Tr "repo.issues.context.copy_link"}}</div>
14+
<div class="item context js-aria-clickable quote-reply {{if .diff}}quote-reply-diff{{end}}" data-target="{{.item.HashTag}}-raw">{{.ctx.locale.Tr "repo.issues.context.quote_reply"}}</div>
1515
{{if not .ctx.UnitIssuesGlobalDisabled}}
16-
<a class="item context reference-issue" data-target="{{.item.HashTag}}-raw" data-modal="#reference-issue-modal" data-poster="{{.item.Poster.GetDisplayName}}" data-poster-username="{{.item.Poster.Name}}" data-reference="{{$referenceUrl}}">{{.ctx.locale.Tr "repo.issues.context.reference_issue"}}</a>
16+
<div class="item context js-aria-clickable reference-issue" data-target="{{.item.HashTag}}-raw" data-modal="#reference-issue-modal" data-poster="{{.item.Poster.GetDisplayName}}" data-poster-username="{{.item.Poster.Name}}" data-reference="{{$referenceUrl}}">{{.ctx.locale.Tr "repo.issues.context.reference_issue"}}</div>
1717
{{end}}
1818
{{if or .ctx.Permission.IsAdmin .IsCommentPoster .ctx.HasIssuesOrPullsWritePermission}}
1919
<div class="divider"></div>
20-
<a class="item context edit-content">{{.ctx.locale.Tr "repo.issues.context.edit"}}</a>
20+
<div class="item context js-aria-clickable edit-content">{{.ctx.locale.Tr "repo.issues.context.edit"}}</div>
2121
{{if .delete}}
22-
<a class="item context delete-comment" data-comment-id={{.item.HashTag}} data-url="{{.ctx.RepoLink}}/comments/{{.item.ID}}/delete" data-locale="{{.ctx.locale.Tr "repo.issues.delete_comment_confirm"}}">{{.ctx.locale.Tr "repo.issues.context.delete"}}</a>
22+
<div class="item context js-aria-clickable delete-comment" data-comment-id={{.item.HashTag}} data-url="{{.ctx.RepoLink}}/comments/{{.item.ID}}/delete" data-locale="{{.ctx.locale.Tr "repo.issues.delete_comment_confirm"}}">{{.ctx.locale.Tr "repo.issues.context.delete"}}</div>
2323
{{end}}
2424
{{end}}
2525
</div>

web_src/js/features/aria.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,9 @@ function attachOneDropdownAria($dropdown) {
8383
if (e.key === 'Enter') {
8484
let $item = $dropdown.dropdown('get item', $dropdown.dropdown('get value'));
8585
if (!$item) $item = $menu.find('> .item.selected'); // when dropdown filters items by input, there is no "value", so query the "selected" item
86-
// if the selected item is clickable, then trigger the click event. in the future there could be a special CSS class for it.
87-
if ($item && $item.is('a')) $item[0].click();
86+
// if the selected item is clickable, then trigger the click event.
87+
// we can not click any item without check, because Fomantic code might also handle the Enter event. that would result in double click.
88+
if ($item && ($item.is('a') || $item.is('.js-aria-clickable'))) $item[0].click();
8889
}
8990
});
9091

0 commit comments

Comments
 (0)