-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Convert <div class="button">
to <button class="button">
#23337
Conversation
This improves a lot of accessibility shortcomings. Every possible instance matching the command `ag '<[^ab].*?class=.*?[" ]button[ "]' templates/ | grep -v 'dropdown'` has been converted when possible. Furthermore, all `cancel` buttons received `type="button"` so that they don't accidentally trigger an underlying form. Lastly, some small and minor issues were fixed as well while refactoring.
This comment was marked as off-topic.
This comment was marked as off-topic.
Most notably, this includes automatically setting 'type="button"' for all cancel buttons, and 'e.preventDefault()' when opening a modal.
Additionally, prevent the default event propagation for all buttons with JS, convert `event` to `e` in `web_src/js/features/common-global.js` for consistency and add fontawesome-save svg. Closes #2 Co-authored-by: wxiaoguang <[email protected]> Co-authored-by: silverwind <[email protected]>
@wxiaoguang @silverwind all done. |
According to https://github.com/go-gitea/gitea/blob/main/docs/content/doc/developers/guidelines-refactoring.en-us.md
😆 |
Indeed, we have now met that criteria with my +1. I will let someone else be the merger on this, although I suspect with branch rules it'll need to be a TOC member who can use 🧙 powers. Of course, if it doesn't get merged in enough time I can be the merger if needed (please ping if that is the case). |
I was unable to create a backport for 1.19, please send one manually. 🍵 |
Does this PR really need to be backported? I am a little worried about whether it would break something, because the button behavior / focus behavior change more or less. Keep it in 1.20 for long enough time before backport? |
Caught one 500 (not sure whether it's related) http://localhost:3000/user/settings/repos template: base/delete_modal_actions:4:11: executing "base/delete_modal_actions" at <.locale.Tr>: can't evaluate field locale in type string |
Caught by @wxiaoguang in #23337 (comment). Additionally, there were three instances that have the same content as `templates/base/deletion_modal_actions.tmpl` but that are not intended to delete something. Instead of renaming the template above, these instances were simply re-hard-coded again. Renaming/improving the template above is left for future PRs.
This improves a lot of accessibility shortcomings.
Every possible instance of
<div class="button">
matching the commandag '<[^ab].*?class=.*?[" ]button[ "]' templates/ | grep -v 'dropdown'
has been converted when possible.divs with the
dropdown
class and their children were omitted asbutton
instead of adiv
.div
s as children. The HTML standard disallowsdiv
s insidebutton
s.button
, the dropdown can be focused twiceFurther 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 #23337 (comment),
<a>
s withouthref
attribute are not focusable.They should later on be converted to
<button>
s.