Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes a11y behaviour for reaction button and comment options button in an issue view #21743

Closed
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
7df8d5f
Fixes a11y behaviour for reactions and options in issue comments view
fsologureng Nov 8, 2022
71008fd
Set last login when activating account (#21731)
wolfogre Nov 9, 2022
f5c8daf
Fix lint errors.
fsologureng Nov 9, 2022
a557912
Merge branch 'main' into gitea-fix-a11y-issue-comments
fsologureng Nov 9, 2022
a5c5705
Merge branch 'main' into gitea-fix-a11y-issue-comments
fsologureng Nov 10, 2022
950ee8e
Fix dashboard ignored system setting cache (#21621)
lunny Nov 10, 2022
8e02e15
Extract updateSession function to reduce repetition (#21735)
wolfogre Nov 10, 2022
bd3e99b
Init git module before database migration (#21764)
wxiaoguang Nov 10, 2022
d2e5120
Revert unrelated changes for SMTP auth (#21767)
wxiaoguang Nov 10, 2022
b97d01e
Extend and fix [7df8d5f36d74a431a301f9f7a9f620ca0318d183]
fsologureng Nov 11, 2022
aae1d7b
Merge branch 'main' into gitea-fix-a11y-issue-comments
fsologureng Nov 11, 2022
52f3eda
Merge branch 'main' into gitea-fix-a11y-issue-comments
fsologureng Nov 11, 2022
2836cfd
Merge branch 'main' into gitea-fix-a11y-issue-comments
fsologureng Nov 12, 2022
f96187f
Upgrade golang.org/x/crypto (#21792)
Nov 13, 2022
62f360f
Render number of commits in repo page in a user friendly way (#21786)
yardenshoham Nov 13, 2022
073455b
Fix webhook attachment text is not set in review comment (#21763)
jim-kirisame Nov 13, 2022
3a93f5c
Add plural definitions for German translations (#21802)
delvh Nov 13, 2022
7c42b3b
fix webpackChunkName for citation-js-csl (#21806)
silverwind Nov 13, 2022
feb2731
Prevent panic in doctor command when running default checks (#21791)
zeripath Nov 13, 2022
3e3150a
Improve pull/ push mirror documentation (especially for GitHub) (#21801)
delvh Nov 14, 2022
9e255cf
Remove `href="javascript:;"` in "save topics (Done)" button (#21813)
yardenshoham Nov 15, 2022
959e64e
Adjust gitea doctor --run storages to check all storage types (#21785)
zeripath Nov 15, 2022
4cf8c4c
Add `updated_at` field to PullReview API object (#21812)
yardenshoham Nov 15, 2022
a42675c
Skip GitHub migration tests if the API token is undefined (#21824)
garymoon Nov 15, 2022
3aa1484
Added space between avatar and username (#21825)
MayMeow Nov 15, 2022
af4a070
Ignore issue template with a special name (#21830)
wolfogre Nov 16, 2022
d936168
Tweak katex options (#21828)
silverwind Nov 17, 2022
296e4ce
Fix setting HTTP headers after write (#21833)
KN4CK3R Nov 17, 2022
d459d0a
Do not allow Ghost access to limited visible user/org (#21849)
KN4CK3R Nov 17, 2022
d8ef6ce
Bump loader-utils from 2.0.3 to 2.0.4 (#21852)
dependabot[bot] Nov 18, 2022
8def283
Fix "build from source" document to clarify the `bindata` tag is requ…
wxiaoguang Nov 18, 2022
003ad30
Prevent dangling user redirects (#21856)
Nov 18, 2022
92697c8
chore: add webpack export type check (#21857)
kecrily Nov 18, 2022
7caa0b7
Fix webpack license warning (#21815)
silverwind Nov 18, 2022
fbad0fc
Timeline and color tweaks (#21799)
silverwind Nov 19, 2022
82110fe
Add `context.Context` to more methods (#21546)
KN4CK3R Nov 19, 2022
1b2470c
Show syntax lexer name in file view/blame (#21814)
silverwind Nov 19, 2022
4e5c491
Fix wechatwork webhook sends empty content in PR review (#21762)
jim-kirisame Nov 19, 2022
7cf816d
Support comma-delimited string as labels in issue template (#21831)
wolfogre Nov 19, 2022
f40ea41
Add package registry cleanup rules (#21658)
KN4CK3R Nov 20, 2022
cd47fb4
Improve documentation for PAM and static deployment (#21866)
KB3HNS Nov 20, 2022
5b4113c
Consolidate security-check into checks-backend (#21882)
silverwind Nov 21, 2022
50af57f
Allow disable RSS/Atom feed (#21622)
Nov 21, 2022
2faaf81
Replace yaml.v2 with yaml.v3 (#21832)
wolfogre Nov 21, 2022
8c6bcda
Improvements for Content Copy (#21842)
silverwind Nov 21, 2022
77ad37b
fix(web): add `alt` for logo in home page (#21887)
kecrily Nov 21, 2022
8248ae9
Embed Matrix icon as SVG (#21890)
silverwind Nov 21, 2022
0451b24
Webhook list enhancements (#21893)
silverwind Nov 21, 2022
0958e6c
Update JS dependencies (#21881)
silverwind Nov 22, 2022
05b73aa
Clarify logging documentation (#21665)
mpeter50 Nov 22, 2022
4a5afa1
Fixes #21895: standardize UTC tz for util tests (#21897)
fsologureng Nov 22, 2022
e0467a7
Prepend refs/heads/ to issue template refs (#20461)
zeripath Nov 22, 2022
d6afc99
Merge branch 'main' into gitea-fix-a11y-issue-comments
fsologureng Nov 22, 2022
f3b3149
Improvements for Content Copy (#21842)
silverwind Nov 21, 2022
40cdd3c
Revert failed merge "Improvements for Content Copy (#21842)"
fsologureng Nov 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1333,6 +1333,7 @@ issues.draft_title = Draft
issues.num_comments = %d comments
issues.commented_at = `commented <a href="#%s">%s</a>`
issues.delete_comment_confirm = Are you sure you want to delete this comment?
issues.context.options_button = Comment Options
issues.context.copy_link = Copy Link
issues.context.quote_reply = Quote Reply
issues.context.reference_issue = Reference in new issue
Expand Down
10 changes: 5 additions & 5 deletions templates/repo/issue/view_content/add_reaction.tmpl
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{{if .ctx.IsSigned}}
<div class="item action ui pointing select-reaction dropdown top right" data-action-url="{{.ActionURL}}">
<a class="add-reaction">
<div class="item action ui pointing select-reaction dropdown top right" role="menu" aria-haspopup="menu" aria-expanded="false" aria-label="{{.ctx.locale.Tr "repo.pick_reaction"}}" tabindex="0" data-action-url="{{.ActionURL}}" data-aria-templated="true">
<a class="add-reaction" role="none" aria-hidden="true">
{{svg "octicon-smiley"}}
</a>
<div class="menu">
<div class="header">{{.ctx.locale.Tr "repo.pick_reaction"}}</div>
<div class="divider"></div>
<div class="header" role="none">{{.ctx.locale.Tr "repo.pick_reaction"}}</div>
<div class="divider" role="none"></div>
{{range $value := AllowedReactions}}
<div class="item reaction tooltip" data-content="{{$value}}">{{ReactionToEmoji $value}}</div>
<div class="item reaction tooltip" role="menuitem" aria-label="{{$value}}" tabindex="-1" data-content="{{$value}}">{{ReactionToEmoji $value}}</div>
{{end}}
</div>
</div>
Expand Down
16 changes: 8 additions & 8 deletions templates/repo/issue/view_content/context_menu.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{if .ctx.IsSigned}}
<div class="item action ui pointing custom dropdown top right context-dropdown">
<a class="context-menu">
<div class="item action ui pointing custom dropdown top right context-dropdown" role="menu" aria-haspopup="menu" aria-expanded="false" aria-label="{{.locale.Tr "repo.issues.context.options_button"}}" tabindex="0" data-aria-templated="true">
<a class="context-menu" role="none" aria-hidden="true">
{{svg "octicon-kebab-horizontal"}}
</a>
<div class="menu">
Expand All @@ -10,16 +10,16 @@
{{else}}
{{$referenceUrl = Printf "%s/files#%s" .ctx.Issue.HTMLURL .item.HashTag}}
{{end}}
<div class="item context" data-clipboard-text="{{$referenceUrl}}">{{.ctx.locale.Tr "repo.issues.context.copy_link"}}</div>
<div class="item context quote-reply {{if .diff}}quote-reply-diff{{end}}" data-target="{{.item.ID}}">{{.ctx.locale.Tr "repo.issues.context.quote_reply"}}</div>
<div class="item context" role="menuitem" tabindex="-1" data-clipboard-text="{{$referenceUrl}}">{{.ctx.locale.Tr "repo.issues.context.copy_link"}}</div>
<div class="item context quote-reply {{if .diff}}quote-reply-diff{{end}}" role="menuitem" tabindex="-1" data-target="{{.item.ID}}">{{.ctx.locale.Tr "repo.issues.context.quote_reply"}}</div>
{{if not .ctx.UnitIssuesGlobalDisabled}}
<div class="item context reference-issue" data-target="{{.item.ID}}" 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>
<div class="item context reference-issue" role="menuitem" tabindex="-1" data-target="{{.item.ID}}" 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>
{{end}}
{{if or .ctx.Permission.IsAdmin .IsCommentPoster .ctx.HasIssuesOrPullsWritePermission}}
<div class="divider"></div>
<div class="item context edit-content">{{.ctx.locale.Tr "repo.issues.context.edit"}}</div>
<div class="divider" role="none"></div>
<div class="item context edit-content" role="menuitem" tabindex="-1">{{.ctx.locale.Tr "repo.issues.context.edit"}}</div>
{{if .delete}}
<div 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"}}</div>
<div class="item context delete-comment" role="menuitem" tabindex="-1" 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>
{{end}}
{{end}}
</div>
Expand Down
44 changes: 43 additions & 1 deletion web_src/js/features/aria.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,48 @@ function attachOneDropdownAria($dropdown) {
$dropdown.on('keyup', (e) => { if (e.key.startsWith('Arrow')) deferredRefreshAria(); });
}

function attachOneDropdownAriaTemplated($dropdown) {
if ($dropdown.attr('data-aria-attached')) return;
$dropdown.attr('data-aria-attached', 1);

const $menu = $dropdown.find('> .menu');
// update aria attributes according to current active/selected item
const refreshAria = () => {
const isMenuVisible = !$menu.is('.hidden') && !$menu.is('.animating.out');
if (isMenuVisible) {
$dropdown.attr('aria-expanded', 'true');
} else {
$dropdown.removeAttr('aria-expanded');
}

let $active = $menu.find('> .item.active');
if (!$active.length) $active = $menu.find('> .item.selected'); // it's strange that we need this fallback at the moment

// if there is an active item, use its id. if no active item, then the empty string is set
$dropdown.attr('aria-activedescendant', $active.attr('id'));
};

$dropdown.on('keydown', (e) => {
// here it must use keydown event before dropdown's keyup handler, otherwise there is no Enter event in our keyup handler
if (e.key === 'Enter') {
const $item = $dropdown.dropdown('get item', $dropdown.dropdown('get value'));
// 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[0].click();
} else if (e.key === 'ESC') {
$dropdown.dropdown('hide');
$dropdown.removeAttr('aria-expanded');
}
});

// use setTimeout to run the refreshAria in next tick (to make sure the Fomantic UI code has finished its work)
const deferredRefreshAria = () => { setTimeout(refreshAria, 0) }; // do not return any value, jQuery has return-value related behaviors.
$dropdown.on('focus', deferredRefreshAria);
$dropdown.on('mouseup', deferredRefreshAria);
$dropdown.on('blur', deferredRefreshAria);
$dropdown.on('keyup', (e) => { if (e.key.startsWith('Arrow')) deferredRefreshAria(); });
}

export function attachDropdownAria($dropdowns) {
$dropdowns.each((_, e) => attachOneDropdownAria($(e)));
$dropdowns.filter(':not([data-aria-templated])').each((_, e) => attachOneDropdownAria($(e)));
$dropdowns.filter('[data-aria-templated]').each((_, e) => attachOneDropdownAriaTemplated($(e)));
}