diff options
author | Otto <otto@codeberg.org> | 2024-12-30 21:28:53 +0100 |
---|---|---|
committer | Otto <otto@codeberg.org> | 2024-12-30 21:28:53 +0100 |
commit | ceee649086bc3bb1ab81a79555c0a6c643654060 (patch) | |
tree | 44195b203a9422c2dd159073021e29daaee934e5 | |
parent | Merge pull request 'Rework user profile settings' (#6407) from fnetx/profile-... (diff) | |
parent | Fix issue/comment menus (diff) | |
download | forgejo-ceee649086bc3bb1ab81a79555c0a6c643654060.tar.xz forgejo-ceee649086bc3bb1ab81a79555c0a6c643654060.zip |
Merge pull request 'Fix issue/comment menus' (#6419) from fnetx/issue-view-a11y into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6419
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
-rw-r--r-- | options/locale/locale_en-US.ini | 6 | ||||
-rw-r--r-- | templates/repo/issue/view_content/add_reaction.tmpl | 2 | ||||
-rw-r--r-- | templates/repo/issue/view_content/context_menu.tmpl | 2 | ||||
-rw-r--r-- | templates/repo/issue/view_content/reactions.tmpl | 15 | ||||
-rw-r--r-- | templates/shared/combomarkdowneditor.tmpl | 4 | ||||
-rw-r--r-- | tests/e2e/issue-comment.test.e2e.ts | 13 | ||||
-rw-r--r-- | web_src/js/modules/tippy.js | 5 |
7 files changed, 39 insertions, 8 deletions
diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index c14b377e50..ca247ff6a2 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1635,6 +1635,12 @@ issues.num_reviews_one = %d review issues.num_reviews_few = %d reviews issues.commented_at = `commented <a href="#%s">%s</a>` issues.delete_comment_confirm = Are you sure you want to delete this comment? +issues.reaction.add = Add reaction +issues.reaction.alt_few = %[1]s reacted %[2]s. +issues.reaction.alt_many = %[1]s and %[2]d more reacted %[3]s. +issues.reaction.alt_remove = Remove %[1]s reaction from comment. +issues.reaction.alt_add = Add %[1]s reaction to comment. +issues.context.menu = Comment menu issues.context.copy_link = Copy link issues.context.quote_reply = Quote reply issues.context.reference_issue = Reference in a new issue diff --git a/templates/repo/issue/view_content/add_reaction.tmpl b/templates/repo/issue/view_content/add_reaction.tmpl index 37931f287e..5d4aa2298e 100644 --- a/templates/repo/issue/view_content/add_reaction.tmpl +++ b/templates/repo/issue/view_content/add_reaction.tmpl @@ -1,5 +1,5 @@ {{if .ctxData.IsSigned}} -<div class="item action ui dropdown jump pointing top right select-reaction" data-action-url="{{.ActionURL}}"> +<div class="item action ui dropdown jump pointing top right select-reaction" data-action-url="{{.ActionURL}}" aria-label="{{ctx.Locale.Tr "repo.issues.reaction.add"}}"> <a class="add-reaction muted"> {{svg "octicon-smiley"}} </a> diff --git a/templates/repo/issue/view_content/context_menu.tmpl b/templates/repo/issue/view_content/context_menu.tmpl index f020a9ea4b..5fc5af400f 100644 --- a/templates/repo/issue/view_content/context_menu.tmpl +++ b/templates/repo/issue/view_content/context_menu.tmpl @@ -1,4 +1,4 @@ -<div class="item action ui dropdown jump pointing top right context-dropdown"> +<div class="item action ui dropdown jump pointing top right context-dropdown" aria-label="{{ctx.Locale.Tr "repo.issues.context.menu"}}"> <a class="context-menu muted"> {{svg "octicon-kebab-horizontal"}} </a> diff --git a/templates/repo/issue/view_content/reactions.tmpl b/templates/repo/issue/view_content/reactions.tmpl index da6319667b..e5cb9a8ed3 100644 --- a/templates/repo/issue/view_content/reactions.tmpl +++ b/templates/repo/issue/view_content/reactions.tmpl @@ -2,9 +2,18 @@ {{range $key, $value := .Reactions}} {{$hasReacted := $value.HasUser $.ctxData.SignedUserID}} <a role="button" class="ui label basic{{if $hasReacted}} primary{{end}}{{if not $.ctxData.IsSigned}} disabled{{end}} comment-reaction-button" - data-tooltip-content - title="{{$value.GetFirstUsers}}{{if gt ($value.GetMoreUserCount) 0}} {{ctx.Locale.Tr "repo.reactions_more" $value.GetMoreUserCount}}{{end}}" - aria-label="{{$value.GetFirstUsers}}{{if gt ($value.GetMoreUserCount) 0}} {{ctx.Locale.Tr "repo.reactions_more" $value.GetMoreUserCount}}{{end}}" + title="{{$value.GetFirstUsers}}" + aria-label=" + {{if eq ($value.GetMoreUserCount) 0}} + {{ctx.Locale.Tr "repo.issues.reaction.alt_few" $value.GetFirstUsers $key}} + {{else}} + {{ctx.Locale.Tr "repo.issues.reaction.alt_many" $value.GetFirstUsers $value.GetMoreUserCount $key}} + {{end}} + {{if $hasReacted}} + {{ctx.Locale.Tr "repo.issues.reaction.alt_remove" $key}} + {{else}} + {{ctx.Locale.Tr "repo.issues.reaction.alt_add" $key}} + {{end}}" data-tooltip-placement="bottom-start" data-reaction-content="{{$key}}" data-has-reacted="{{$hasReacted}}"> <span class="reaction">{{ReactionToEmoji $key}}</span> diff --git a/templates/shared/combomarkdowneditor.tmpl b/templates/shared/combomarkdowneditor.tmpl index 9fcab8a9ae..e7bace6962 100644 --- a/templates/shared/combomarkdowneditor.tmpl +++ b/templates/shared/combomarkdowneditor.tmpl @@ -37,14 +37,14 @@ Template Attributes: <md-task-list class="markdown-toolbar-button" data-tooltip-content="{{ctx.Locale.Tr "editor.buttons.list.task.tooltip"}}">{{svg "octicon-tasklist"}}</md-task-list> <button type="button" class="markdown-toolbar-button" data-md-button data-md-action="unindent" data-tooltip-content="{{ctx.Locale.Tr "editor.buttons.unindent.tooltip"}}">{{svg "octicon-arrow-left"}}</button> <button type="button" class="markdown-toolbar-button" data-md-button data-md-action="indent" data-tooltip-content="{{ctx.Locale.Tr "editor.buttons.indent.tooltip"}}">{{svg "octicon-arrow-right"}}</button> - <button type="button" class="markdown-toolbar-button show-modal button" data-md-action="new-table" data-tooltip-content="{{ctx.Locale.Tr "editor.buttons.new_table.tooltip"}}">{{svg "octicon-table"}}</button> </div> <div class="markdown-toolbar-group"> + <button type="button" class="markdown-toolbar-button show-modal button" data-md-button data-md-action="new-table" data-tooltip-content="{{ctx.Locale.Tr "editor.buttons.new_table.tooltip"}}">{{svg "octicon-table"}}</button> <md-mention class="markdown-toolbar-button" data-tooltip-content="{{ctx.Locale.Tr "editor.buttons.mention.tooltip"}}">{{svg "octicon-mention"}}</md-mention> <md-ref class="markdown-toolbar-button" data-tooltip-content="{{ctx.Locale.Tr "editor.buttons.ref.tooltip"}}">{{svg "octicon-cross-reference"}}</md-ref> </div> <div class="markdown-toolbar-group"> - <button class="markdown-toolbar-button markdown-switch-monospace" role="switch" data-enable-text="{{ctx.Locale.Tr "editor.buttons.enable_monospace_font"}}" data-disable-text="{{ctx.Locale.Tr "editor.buttons.disable_monospace_font"}}">{{svg "octicon-typography"}}</button> + <button class="markdown-toolbar-button markdown-switch-monospace" data-md-button role="switch" data-enable-text="{{ctx.Locale.Tr "editor.buttons.enable_monospace_font"}}" data-disable-text="{{ctx.Locale.Tr "editor.buttons.disable_monospace_font"}}">{{svg "octicon-typography"}}</button> {{if .EasyMDE}} <button class="markdown-toolbar-button markdown-switch-easymde" data-tooltip-content="{{ctx.Locale.Tr "editor.buttons.switch_to_legacy.tooltip"}}">{{svg "octicon-arrow-switch"}}</button> {{end}} diff --git a/tests/e2e/issue-comment.test.e2e.ts b/tests/e2e/issue-comment.test.e2e.ts index f493f64506..4fce16764b 100644 --- a/tests/e2e/issue-comment.test.e2e.ts +++ b/tests/e2e/issue-comment.test.e2e.ts @@ -11,6 +11,19 @@ test.beforeAll(async ({browser}, workerInfo) => { await login_user(browser, workerInfo, 'user2'); }); +test('Menu accessibility', async ({browser}, workerInfo) => { + const page = await login({browser}, workerInfo); + await page.goto('/user2/repo1/issues/1'); + await expect(page.getByLabel('user2 reacted eyes. Remove eyes')).toBeVisible(); + await expect(page.getByLabel('reacted laugh. Remove laugh')).toBeVisible(); + await expect(page.locator('#issue-1').getByLabel('Comment menu')).toBeVisible(); + await expect(page.locator('#issue-1').getByRole('heading').getByLabel('Add reaction')).toBeVisible(); + page.getByLabel('reacted laugh. Remove').click(); + await expect(page.getByLabel('user1 reacted laugh. Add laugh')).toBeVisible(); + page.getByLabel('user1 reacted laugh.').click(); + await expect(page.getByLabel('user1, user2 reacted laugh. Remove laugh')).toBeVisible(); +}); + test('Hyperlink paste behaviour', async ({browser}, workerInfo) => { test.skip(['Mobile Safari', 'Mobile Chrome', 'webkit'].includes(workerInfo.project.name), 'Mobile clients seem to have very weird behaviour with this test, which I cannot confirm with real usage'); const page = await login({browser}, workerInfo); diff --git a/web_src/js/modules/tippy.js b/web_src/js/modules/tippy.js index 83b28e5745..887e7194d9 100644 --- a/web_src/js/modules/tippy.js +++ b/web_src/js/modules/tippy.js @@ -103,7 +103,10 @@ function switchTitleToTooltip(target) { } } target.setAttribute('data-tooltip-content', title); - target.setAttribute('aria-label', title); + // only replace if not explicitly set + if (target.getAttribute('aria-label') !== null) { + target.setAttribute('aria-label', title); + } // keep the attribute, in case there are some other "[title]" selectors // and to prevent infinite loop with <relative-time> which will re-add // title if it is absent |