diff options
author | delvh <leon@kske.dev> | 2023-03-14 04:34:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-14 11:34:09 +0800 |
commit | 81fe5d61851c0e586af7d32c29171ceff9a571bb (patch) | |
tree | 40ea13c9726cfca88a83800b323b428438cd90e9 /templates/repo/issue | |
parent | 605fd15ad6eda19dba8f5e8a8f2e595e34e6c6ee (diff) | |
download | gitea-81fe5d61851c0e586af7d32c29171ceff9a571bb.tar.gz gitea-81fe5d61851c0e586af7d32c29171ceff9a571bb.zip |
Convert `<div class="button">` to `<button class="button">` (#23337)
This improves a lot of accessibility shortcomings.
Every possible instance of `<div class="button">` matching the command
`ag '<[^ab].*?class=.*?[" ]button[ "]' templates/ | grep -v 'dropdown'`
has been converted when possible.
divs with the `dropdown` class and their children were omitted as
1. more analysis must be conducted whether the dropdowns still work as
intended when they are a `button` instead of a `div`.
2. most dropdowns have `div`s as children. The HTML standard disallows
`div`s inside `button`s.
3. When a dropdown child that's part of the displayed text content is
converted to a `button`, the dropdown can be focused twice
Further changes include that all "gitea-managed" buttons with JS code
received an `e.preventDefault()` so that they don't accidentally submit
an underlying form, which would execute instead of cancel the action.
Lastly, some minor issues were fixed as well during the refactoring.
## Future improvements
As mentioned in
https://github.com/go-gitea/gitea/pull/23337#discussion_r1127277391,
`<a>`s without `href` attribute are not focusable.
They should later on be converted to `<button>`s.
---------
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'templates/repo/issue')
-rw-r--r-- | templates/repo/issue/labels.tmpl | 2 | ||||
-rw-r--r-- | templates/repo/issue/labels/edit_delete_label.tmpl | 21 | ||||
-rw-r--r-- | templates/repo/issue/labels/label_new.tmpl | 11 | ||||
-rw-r--r-- | templates/repo/issue/list.tmpl | 4 | ||||
-rw-r--r-- | templates/repo/issue/milestone_issues.tmpl | 4 | ||||
-rw-r--r-- | templates/repo/issue/milestones.tmpl | 11 | ||||
-rw-r--r-- | templates/repo/issue/view_content.tmpl | 20 | ||||
-rw-r--r-- | templates/repo/issue/view_content/comments_delete_time.tmpl | 5 | ||||
-rw-r--r-- | templates/repo/issue/view_content/pull.tmpl | 2 | ||||
-rw-r--r-- | templates/repo/issue/view_content/sidebar.tmpl | 16 | ||||
-rw-r--r-- | templates/repo/issue/view_content/update_branch_by_merge.tmpl | 4 | ||||
-rw-r--r-- | templates/repo/issue/view_title.tmpl | 4 |
12 files changed, 43 insertions, 61 deletions
diff --git a/templates/repo/issue/labels.tmpl b/templates/repo/issue/labels.tmpl index 82cfcd0712..0a25d9c87f 100644 --- a/templates/repo/issue/labels.tmpl +++ b/templates/repo/issue/labels.tmpl @@ -6,7 +6,7 @@ {{template "repo/issue/navbar" .}} {{if and (or .CanWriteIssues .CanWritePulls) (not .Repository.IsArchived)}} <div class="ui right"> - <div class="ui green new-label button">{{.locale.Tr "repo.issues.new_label"}}</div> + <button class="ui green new-label button">{{.locale.Tr "repo.issues.new_label"}}</button> </div> {{end}} </div> diff --git a/templates/repo/issue/labels/edit_delete_label.tmpl b/templates/repo/issue/labels/edit_delete_label.tmpl index 450061e835..38a948172f 100644 --- a/templates/repo/issue/labels/edit_delete_label.tmpl +++ b/templates/repo/issue/labels/edit_delete_label.tmpl @@ -6,16 +6,7 @@ <div class="content"> <p>{{.locale.Tr "repo.issues.label_deletion_desc"}}</p> </div> - <div class="actions"> - <div class="ui red basic inverted cancel button"> - <i class="remove icon"></i> - {{.locale.Tr "modal.no"}} - </div> - <div class="ui green basic inverted ok button"> - <i class="checkmark icon"></i> - {{.locale.Tr "modal.yes"}} - </div> - </div> + {{template "base/delete_modal_actions" .}} </div> <div class="ui small edit-label modal"> @@ -61,11 +52,13 @@ </form> </div> <div class="actions"> - <div class="ui secondary small basic cancel button"> + <button class="ui secondary small basic cancel button"> + {{svg "octicon-x"}} {{.locale.Tr "cancel"}} - </div> - <div class="ui primary small approve button"> + </button> + <button class="ui primary small approve button"> + <i class="save icon"></i> {{.locale.Tr "save"}} - </div> + </button> </div> </div> diff --git a/templates/repo/issue/labels/label_new.tmpl b/templates/repo/issue/labels/label_new.tmpl index 62f7155b74..c937f28e8a 100644 --- a/templates/repo/issue/labels/label_new.tmpl +++ b/templates/repo/issue/labels/label_new.tmpl @@ -36,12 +36,15 @@ </div> </form> </div> + <div class="actions"> - <div class="ui secondary small basic cancel button"> + <button class="ui red basic inverted cancel button"> + {{svg "octicon-x"}} {{.locale.Tr "cancel"}} - </div> - <div class="ui primary small approve button"> + </button> + <button class="ui green basic inverted ok button"> + {{svg "octicon-check"}} {{.locale.Tr "repo.issues.create_label"}} - </div> + </button> </div> </div> diff --git a/templates/repo/issue/list.tmpl b/templates/repo/issue/list.tmpl index ca05264e77..36faf86113 100644 --- a/templates/repo/issue/list.tmpl +++ b/templates/repo/issue/list.tmpl @@ -213,9 +213,9 @@ {{if not .Repository.IsArchived}} <!-- Action Button --> {{if .IsShowClosed}} - <div class="ui green active basic button issue-action" data-action="open" data-url="{{$.RepoLink}}/issues/status" style="margin-left: auto">{{.locale.Tr "repo.issues.action_open"}}</div> + <button class="ui green active basic button issue-action" data-action="open" data-url="{{$.RepoLink}}/issues/status" style="margin-left: auto">{{.locale.Tr "repo.issues.action_open"}}</button> {{else}} - <div class="ui red active basic button issue-action" data-action="close" data-url="{{$.RepoLink}}/issues/status" style="margin-left: auto">{{.locale.Tr "repo.issues.action_close"}}</div> + <button class="ui red active basic button issue-action" data-action="close" data-url="{{$.RepoLink}}/issues/status" style="margin-left: auto">{{.locale.Tr "repo.issues.action_close"}}</button> {{end}} <!-- Labels --> <div class="ui {{if not .Labels}}disabled{{end}} dropdown jump item"> diff --git a/templates/repo/issue/milestone_issues.tmpl b/templates/repo/issue/milestone_issues.tmpl index 2918c4359f..b4f036d32a 100644 --- a/templates/repo/issue/milestone_issues.tmpl +++ b/templates/repo/issue/milestone_issues.tmpl @@ -149,9 +149,9 @@ <div class="ui secondary filter stackable menu"> <!-- Action Button --> {{if .IsShowClosed}} - <div class="ui green active basic button issue-action" data-action="open" data-url="{{$.RepoLink}}/issues/status" style="margin-left: auto">{{.locale.Tr "repo.issues.action_open"}}</div> + <button class="ui green active basic button issue-action" data-action="open" data-url="{{$.RepoLink}}/issues/status" style="margin-left: auto">{{.locale.Tr "repo.issues.action_open"}}</button> {{else}} - <div class="ui red active basic button issue-action" data-action="close" data-url="{{$.RepoLink}}/issues/status" style="margin-left: auto">{{.locale.Tr "repo.issues.action_close"}}</div> + <button class="ui red active basic button issue-action" data-action="close" data-url="{{$.RepoLink}}/issues/status" style="margin-left: auto">{{.locale.Tr "repo.issues.action_close"}}</button> {{end}} <!-- Labels --> <div class="ui {{if not .Labels}}disabled{{end}} dropdown jump item"> diff --git a/templates/repo/issue/milestones.tmpl b/templates/repo/issue/milestones.tmpl index 3730d3d3c4..5797b358f7 100644 --- a/templates/repo/issue/milestones.tmpl +++ b/templates/repo/issue/milestones.tmpl @@ -124,16 +124,7 @@ <div class="content"> <p>{{.locale.Tr "repo.milestones.deletion_desc"}}</p> </div> - <div class="actions"> - <div class="ui red basic inverted cancel button"> - <i class="remove icon"></i> - {{.locale.Tr "modal.no"}} - </div> - <div class="ui green basic inverted ok button"> - <i class="checkmark icon"></i> - {{.locale.Tr "modal.yes"}} - </div> - </div> + {{template "base/delete_modal_actions" .}} </div> {{end}} {{template "base/footer" .}} diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl index 6aec6e3157..f013317ca8 100644 --- a/templates/repo/issue/view_content.tmpl +++ b/templates/repo/issue/view_content.tmpl @@ -112,13 +112,13 @@ <div class="text right"> {{if and (or .HasIssuesOrPullsWritePermission .IsIssuePoster) (not .DisableStatusChange)}} {{if .Issue.IsClosed}} - <div id="status-button" class="ui green basic button" tabindex="6" data-status="{{.locale.Tr "repo.issues.reopen_issue"}}" data-status-and-comment="{{.locale.Tr "repo.issues.reopen_comment_issue"}}" data-status-val="reopen"> + <button id="status-button" class="ui green basic button" tabindex="6" data-status="{{.locale.Tr "repo.issues.reopen_issue"}}" data-status-and-comment="{{.locale.Tr "repo.issues.reopen_comment_issue"}}" data-status-val="reopen"> {{.locale.Tr "repo.issues.reopen_issue"}} - </div> + </button> {{else}} - <div id="status-button" class="ui red basic button" tabindex="6" data-status="{{.locale.Tr "repo.issues.close_issue"}}" data-status-and-comment="{{.locale.Tr "repo.issues.close_comment_issue"}}" data-status-val="close"> + <button id="status-button" class="ui red basic button" tabindex="6" data-status="{{.locale.Tr "repo.issues.close_issue"}}" data-status-and-comment="{{.locale.Tr "repo.issues.close_comment_issue"}}" data-status-val="close"> {{.locale.Tr "repo.issues.close_issue"}} - </div> + </button> {{end}} {{end}} <button class="ui green button loading-button" tabindex="5"> @@ -163,13 +163,13 @@ <div class="text right"> {{if and (or .HasIssuesOrPullsWritePermission .IsIssuePoster) (not .DisableStatusChange)}} {{if .Issue.IsClosed}} - <div id="status-button" class="ui green basic button" tabindex="6" data-status="{{.locale.Tr "repo.issues.reopen_issue"}}" data-status-and-comment="{{.locale.Tr "repo.issues.reopen_comment_issue"}}" data-status-val="reopen"> + <button id="status-button" class="ui green basic button" tabindex="6" data-status="{{.locale.Tr "repo.issues.reopen_issue"}}" data-status-and-comment="{{.locale.Tr "repo.issues.reopen_comment_issue"}}" data-status-val="reopen"> {{.locale.Tr "repo.issues.reopen_issue"}} - </div> + </button> {{else}} - <div id="status-button" class="ui red basic button" tabindex="6" data-status="{{.locale.Tr "repo.issues.close_issue"}}" data-status-and-comment="{{.locale.Tr "repo.issues.close_comment_issue"}}" data-status-val="close"> + <button id="status-button" class="ui red basic button" tabindex="6" data-status="{{.locale.Tr "repo.issues.close_issue"}}" data-status-and-comment="{{.locale.Tr "repo.issues.close_comment_issue"}}" data-status-val="close"> {{.locale.Tr "repo.issues.close_issue"}} - </div> + </button> {{end}} {{end}} <button class="ui green button loading-button" tabindex="5"> @@ -215,8 +215,8 @@ {{end}} <div class="field footer"> <div class="text right edit"> - <div class="ui basic secondary cancel button" tabindex="3">{{.locale.Tr "repo.issues.cancel"}}</div> - <div class="ui primary save button" tabindex="2">{{.locale.Tr "repo.issues.save"}}</div> + <button class="ui basic secondary cancel button" tabindex="3">{{.locale.Tr "repo.issues.cancel"}}</button> + <button class="ui primary save button" tabindex="2">{{.locale.Tr "repo.issues.save"}}</button> </div> </div> </div> diff --git a/templates/repo/issue/view_content/comments_delete_time.tmpl b/templates/repo/issue/view_content/comments_delete_time.tmpl index bc08d7fde7..b79b7ae2be 100644 --- a/templates/repo/issue/view_content/comments_delete_time.tmpl +++ b/templates/repo/issue/view_content/comments_delete_time.tmpl @@ -7,10 +7,7 @@ {{.ctxData.CsrfTokenHtml}} </form> <div class="header">{{.ctxData.locale.Tr "repo.issues.del_time"}}</div> - <div class="actions"> - <div class="ui red approve button">{{.ctxData.locale.Tr "repo.issues.context.delete"}}</div> - <div class="ui cancel button">{{.ctxData.locale.Tr "repo.issues.add_time_cancel"}}</div> - </div> + {{template "base/delete_modal_actions" .}} </div> <button class="ui icon button compact mini issue-delete-time tooltip" data-id="{{.comment.Time.ID}}" data-content="{{.ctxData.locale.Tr "repo.issues.del_time"}}" data-position="top right"> {{svg "octicon-trash"}} diff --git a/templates/repo/issue/view_content/pull.tmpl b/templates/repo/issue/view_content/pull.tmpl index f0bf23c9e9..30345b0138 100644 --- a/templates/repo/issue/view_content/pull.tmpl +++ b/templates/repo/issue/view_content/pull.tmpl @@ -58,7 +58,7 @@ <input id="message" name="message"> </div> <div class="text right actions"> - <div class="ui cancel button">{{$.locale.Tr "settings.cancel"}}</div> + <button class="ui cancel button">{{$.locale.Tr "settings.cancel"}}</button> <button class="ui red button" type="submit">{{$.locale.Tr "ok"}}</button> </div> </form> diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl index e58f94aff3..165dca7e0c 100644 --- a/templates/repo/issue/view_content/sidebar.tmpl +++ b/templates/repo/issue/view_content/sidebar.tmpl @@ -346,8 +346,8 @@ </form> </div> <div class="actions"> - <div class="ui green approve button">{{.locale.Tr "repo.issues.add_time_short"}}</div> - <div class="ui red cancel button">{{.locale.Tr "repo.issues.add_time_cancel"}}</div> + <button class="ui green approve button">{{.locale.Tr "repo.issues.add_time_short"}}</button> + <button class="ui red cancel button">{{.locale.Tr "repo.issues.add_time_cancel"}}</button> </div> </div> <button class="ui fluid button green tooltip issue-add-time gt-mt-3" data-content='{{.locale.Tr "repo.issues.add_time"}}' data-position="top center">{{.locale.Tr "repo.issues.add_time_short"}}</button> @@ -532,14 +532,14 @@ {{end}}</p> </div> <div class="actions"> - <div class="ui red cancel inverted button"> + <button class="ui red cancel inverted button"> {{svg "octicon-x"}} {{.locale.Tr "repo.issues.dependency.cancel"}} - </div> - <div class="ui green ok inverted button"> + </button> + <button class="ui green ok inverted button"> {{svg "octicon-check"}} {{.locale.Tr "repo.issues.dependency.remove"}} - </div> + </button> </div> </div> {{end}} @@ -619,7 +619,7 @@ {{end}} <div class="text right actions"> - <div class="ui cancel button">{{.locale.Tr "settings.cancel"}}</div> + <button class="ui cancel button">{{.locale.Tr "settings.cancel"}}</button> <button class="ui red button"> {{if .Issue.IsLocked}} {{.locale.Tr "repo.issues.unlock_confirm"}} @@ -655,7 +655,7 @@ <form action="{{.Issue.Link}}/delete" method="post"> {{.CsrfTokenHtml}} <div class="center actions"> - <div class="ui basic cancel inverted button">{{.locale.Tr "settings.cancel"}}</div> + <button class="ui basic cancel inverted button">{{.locale.Tr "settings.cancel"}}</button> <button class="ui basic red inverted button">{{.locale.Tr "modal.yes"}}</button> </div> </form> diff --git a/templates/repo/issue/view_content/update_branch_by_merge.tmpl b/templates/repo/issue/view_content/update_branch_by_merge.tmpl index 6d36a9b45f..49e4467dc3 100644 --- a/templates/repo/issue/view_content/update_branch_by_merge.tmpl +++ b/templates/repo/issue/view_content/update_branch_by_merge.tmpl @@ -19,8 +19,8 @@ <div class="ui dropdown icon button no-text"> {{svg "octicon-triangle-down" 14 "dropdown icon"}} <div class="menu"> - <div class="item active selected" data-do="{{.Link}}/update">{{$.locale.Tr "repo.pulls.update_branch"}}</div> - <div class="item" data-do="{{.Link}}/update?style=rebase">{{$.locale.Tr "repo.pulls.update_branch_rebase"}}</div> + <a class="item active selected" data-do="{{.Link}}/update">{{$.locale.Tr "repo.pulls.update_branch"}}</a> + <a class="item" data-do="{{.Link}}/update?style=rebase">{{$.locale.Tr "repo.pulls.update_branch_rebase"}}</a> </div> </div> </div> diff --git a/templates/repo/issue/view_title.tmpl b/templates/repo/issue/view_title.tmpl index f0ac1e021e..2a8381b0b4 100644 --- a/templates/repo/issue/view_title.tmpl +++ b/templates/repo/issue/view_title.tmpl @@ -1,9 +1,7 @@ <div class="sixteen wide column title"> <div class="issue-title" id="issue-title-wrapper"> {{if and (or .HasIssuesOrPullsWritePermission .IsIssuePoster) (not .Repository.IsArchived)}} - <div class="edit-button"> - <button id="edit-title" class="ui basic button secondary not-in-edit">{{.locale.Tr "repo.issues.edit"}}</button> - </div> + <button id="edit-title" class="ui basic button secondary edit-button not-in-edit">{{.locale.Tr "repo.issues.edit"}}</button> {{end}} <h1> <span id="issue-title">{{RenderIssueTitle $.Context .Issue.Title $.RepoLink $.Repository.ComposeMetas | RenderCodeBlock}}</span> |