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/user | |
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/user')
-rw-r--r-- | templates/user/auth/grant.tmpl | 2 | ||||
-rw-r--r-- | templates/user/auth/webauthn_error.tmpl | 2 | ||||
-rw-r--r-- | templates/user/settings/account.tmpl | 4 | ||||
-rw-r--r-- | templates/user/settings/applications.tmpl | 15 | ||||
-rw-r--r-- | templates/user/settings/keys_gpg.tmpl | 2 | ||||
-rw-r--r-- | templates/user/settings/keys_principal.tmpl | 4 | ||||
-rw-r--r-- | templates/user/settings/keys_ssh.tmpl | 6 | ||||
-rw-r--r-- | templates/user/settings/repos.tmpl | 22 | ||||
-rw-r--r-- | templates/user/settings/security/twofa.tmpl | 2 |
9 files changed, 21 insertions, 38 deletions
diff --git a/templates/user/auth/grant.tmpl b/templates/user/auth/grant.tmpl index c906db3e0a..060b675273 100644 --- a/templates/user/auth/grant.tmpl +++ b/templates/user/auth/grant.tmpl @@ -23,7 +23,7 @@ <input type="hidden" name="scope" value="{{.Scope}}"> <input type="hidden" name="nonce" value="{{.Nonce}}"> <input type="hidden" name="redirect_uri" value="{{.RedirectURI}}"> - <input type="submit" id="authorize-app" value="{{.locale.Tr "auth.authorize_application"}}" class="ui red inline button"/> + <button type="submit" id="authorize-app" value="{{.locale.Tr "auth.authorize_application"}}" class="ui red inline button">{{.locale.Tr "auth.authorize_application"}}</button> <a href="{{.RedirectURI}}" class="ui basic primary inline button">Cancel</a> </form> </div> diff --git a/templates/user/auth/webauthn_error.tmpl b/templates/user/auth/webauthn_error.tmpl index 447d289a28..b6467de1aa 100644 --- a/templates/user/auth/webauthn_error.tmpl +++ b/templates/user/auth/webauthn_error.tmpl @@ -17,6 +17,6 @@ </div> <div class="actions"> <button onclick="window.location.reload()" class="success ui button gt-hidden webauthn_error_timeout">{{.locale.Tr "webauthn_reload"}}</button> - <div class="ui cancel button">{{.locale.Tr "cancel"}}</div> + <button class="ui cancel button">{{.locale.Tr "cancel"}}</button> </div> </div> diff --git a/templates/user/settings/account.tmpl b/templates/user/settings/account.tmpl index 9a57bd5722..53f7d021e0 100644 --- a/templates/user/settings/account.tmpl +++ b/templates/user/settings/account.tmpl @@ -151,9 +151,9 @@ <input id="password-confirmation" name="password" type="password" autocomplete="off" required> </div> <div class="field"> - <div class="ui red button delete-button" data-modal-id="delete-account" data-type="form" data-form="#delete-form"> + <button class="ui red button delete-button" data-modal-id="delete-account" data-type="form" data-form="#delete-form"> {{.locale.Tr "settings.confirm_delete_account"}} - </div> + </button> <a href="{{AppSubUrl}}/user/forgot_password?email={{.Email}}">{{.locale.Tr "auth.forgot_password"}}</a> </div> </form> diff --git a/templates/user/settings/applications.tmpl b/templates/user/settings/applications.tmpl index b0cd37d44c..18132c4a75 100644 --- a/templates/user/settings/applications.tmpl +++ b/templates/user/settings/applications.tmpl @@ -276,15 +276,16 @@ <div class="content"> <p>{{.locale.Tr "settings.access_token_deletion_desc"}}</p> </div> - <div class="actions"> - <div class="ui cancel button"> - <i class="remove icon"></i> + + <div class="actions">{{/* TODO: Convert to base/delete_modal_actions.tmpl */}} + <button class="ui green basic inverted cancel button"> + {{svg "octicon-x"}} {{.locale.Tr "settings.access_token_deletion_cancel_action"}} - </div> - <div class="ui red basic inverted ok button"> - <i class="checkmark icon"></i> + </button> + <button class="ui red basic inverted ok button"> + {{svg "octicon-check"}} {{.locale.Tr "settings.access_token_deletion_confirm_action"}} - </div> + </button> </div> </div> diff --git a/templates/user/settings/keys_gpg.tmpl b/templates/user/settings/keys_gpg.tmpl index c80890940a..93ca12a088 100644 --- a/templates/user/settings/keys_gpg.tmpl +++ b/templates/user/settings/keys_gpg.tmpl @@ -1,7 +1,7 @@ <h4 class="ui top attached header"> {{.locale.Tr "settings.manage_gpg_keys"}} <div class="ui right"> - <div class="ui primary tiny show-panel button" data-panel="#add-gpg-key-panel">{{.locale.Tr "settings.add_key"}}</div> + <button class="ui primary tiny show-panel button" data-panel="#add-gpg-key-panel">{{.locale.Tr "settings.add_key"}}</button> </div> </h4> <div class="ui attached segment"> diff --git a/templates/user/settings/keys_principal.tmpl b/templates/user/settings/keys_principal.tmpl index cc1152b739..8012b874cd 100644 --- a/templates/user/settings/keys_principal.tmpl +++ b/templates/user/settings/keys_principal.tmpl @@ -3,9 +3,9 @@ {{.locale.Tr "settings.manage_ssh_principals"}} <div class="ui right"> {{if not .DisableSSH}} - <div class="ui primary tiny show-panel button" data-panel="#add-ssh-principal-panel">{{.locale.Tr "settings.add_new_principal"}}</div> + <button class="ui primary tiny show-panel button" data-panel="#add-ssh-principal-panel">{{.locale.Tr "settings.add_new_principal"}}</button> {{else}} - <div class="ui primary tiny button disabled">{{.locale.Tr "settings.ssh_disabled"}}</div> + <button class="ui primary tiny button disabled">{{.locale.Tr "settings.ssh_disabled"}}</button> {{end}} </div> </h4> diff --git a/templates/user/settings/keys_ssh.tmpl b/templates/user/settings/keys_ssh.tmpl index 891959d351..1ff4dab34e 100644 --- a/templates/user/settings/keys_ssh.tmpl +++ b/templates/user/settings/keys_ssh.tmpl @@ -2,11 +2,11 @@ {{.locale.Tr "settings.manage_ssh_keys"}} <div class="ui right"> {{if not .DisableSSH}} - <div id="add-ssh-button" class="ui primary tiny show-panel button" data-panel="#add-ssh-key-panel"> + <button id="add-ssh-button" class="ui primary tiny show-panel button" data-panel="#add-ssh-key-panel"> {{.locale.Tr "settings.add_key"}} - </div> + </button> {{else}} - <div class="ui primary tiny button disabled">{{.locale.Tr "settings.ssh_disabled"}}</div> + <button class="ui primary tiny button disabled">{{.locale.Tr "settings.ssh_disabled"}}</button> {{end}} </div> </h4> diff --git a/templates/user/settings/repos.tmpl b/templates/user/settings/repos.tmpl index 902b3fb2f3..2e107ca7fa 100644 --- a/templates/user/settings/repos.tmpl +++ b/templates/user/settings/repos.tmpl @@ -50,16 +50,7 @@ {{$.CsrfTokenHtml}} <input type="hidden" name="id" value="{{$dir}}"> <input type="hidden" name="action" value="adopt"> - <div class="actions"> - <div class="ui red basic inverted cancel button"> - <i class="remove icon"></i> - {{$.locale.Tr "modal.no"}} - </div> - <button class="ui green basic inverted ok button"> - <i class="checkmark icon"></i> - {{$.locale.Tr "modal.yes"}} - </button> - </div> + {{template "base/delete_modal_actions" .}} </form> </div> {{end}} @@ -77,16 +68,7 @@ {{$.CsrfTokenHtml}} <input type="hidden" name="id" value="{{$dir}}"> <input type="hidden" name="action" value="delete"> - <div class="actions"> - <div class="ui red basic inverted cancel button"> - <i class="remove icon"></i> - {{$.locale.Tr "modal.no"}} - </div> - <button class="ui green basic inverted ok button"> - <i class="checkmark icon"></i> - {{$.locale.Tr "modal.yes"}} - </button> - </div> + {{template "base/delete_modal_actions" .}} </form> </div> {{end}} diff --git a/templates/user/settings/security/twofa.tmpl b/templates/user/settings/security/twofa.tmpl index a4da947628..1a0a8a6432 100644 --- a/templates/user/settings/security/twofa.tmpl +++ b/templates/user/settings/security/twofa.tmpl @@ -13,7 +13,7 @@ <form class="ui form" action="{{AppSubUrl}}/user/settings/security/two_factor/disable" method="post" enctype="multipart/form-data" id="disable-form"> {{.CsrfTokenHtml}} <p>{{.locale.Tr "settings.twofa_disable_note"}}</p> - <div class="ui red button delete-button" data-modal-id="disable-twofa" data-type="form" data-form="#disable-form">{{$.locale.Tr "settings.twofa_disable"}}</div> + <button class="ui red button delete-button" data-modal-id="disable-twofa" data-type="form" data-form="#disable-form">{{$.locale.Tr "settings.twofa_disable"}}</button> </form> {{else}} <p>{{.locale.Tr "settings.twofa_not_enrolled"}}</p> |