From b70c7f86604185ed18a9d5e3b25327805e2b6a52 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 8 Mar 2023 11:26:37 +0800 Subject: [PATCH] Fix incorrect display for comment context menu (#23343) Replace #23342 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; }` And complete one more of my TODOs: "in the future there could be a special CSS class for it" --- templates/repo/issue/view_content/context_menu.tmpl | 10 +++++----- web_src/js/features/aria.js | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/templates/repo/issue/view_content/context_menu.tmpl b/templates/repo/issue/view_content/context_menu.tmpl index f836271b65..c073c74ea3 100644 --- a/templates/repo/issue/view_content/context_menu.tmpl +++ b/templates/repo/issue/view_content/context_menu.tmpl @@ -10,16 +10,16 @@ {{else}} {{$referenceUrl = Printf "%s/files#%s" .ctxData.Issue.Link .item.HashTag}} {{end}} - {{.ctxData.locale.Tr "repo.issues.context.copy_link"}} - {{.ctxData.locale.Tr "repo.issues.context.quote_reply"}} +
{{.ctxData.locale.Tr "repo.issues.context.copy_link"}}
+
{{.ctxData.locale.Tr "repo.issues.context.quote_reply"}}
{{if not .ctxData.UnitIssuesGlobalDisabled}} - {{.ctxData.locale.Tr "repo.issues.context.reference_issue"}} +
{{.ctxData.locale.Tr "repo.issues.context.reference_issue"}}
{{end}} {{if or .ctxData.Permission.IsAdmin .IsCommentPoster .ctxData.HasIssuesOrPullsWritePermission}}
- {{.ctxData.locale.Tr "repo.issues.context.edit"}} +
{{.ctxData.locale.Tr "repo.issues.context.edit"}}
{{if .delete}} - {{.ctxData.locale.Tr "repo.issues.context.delete"}} +
{{.ctxData.locale.Tr "repo.issues.context.delete"}}
{{end}} {{end}} diff --git a/web_src/js/features/aria.js b/web_src/js/features/aria.js index 373d667c5f..46944336ad 100644 --- a/web_src/js/features/aria.js +++ b/web_src/js/features/aria.js @@ -83,8 +83,9 @@ function attachOneDropdownAria($dropdown) { if (e.key === 'Enter') { let $item = $dropdown.dropdown('get item', $dropdown.dropdown('get value')); if (!$item) $item = $menu.find('> .item.selected'); // when dropdown filters items by input, there is no "value", so query the "selected" item - // if the selected item is clickable, then trigger the click event. in the future there could be a special CSS class for it. - if ($item && $item.is('a')) $item[0].click(); + // if the selected item is clickable, then trigger the click event. + // we can not click any item without check, because Fomantic code might also handle the Enter event. that would result in double click. + if ($item && ($item.is('a') || $item.is('.js-aria-clickable'))) $item[0].click(); } });