fix: use button to replace anchor elements without href (#40338)

Elements `<a>` without `href` are not focus-able, screen readers didn't
expose it as a button.

Use `<button type="button">` for these elements, and fix what the
conversion exposed:

- Disabled reactions and the copy-content button use `aria-disabled`,
because native `disabled` suppresses their tooltips
- The random label color button gets a label
- Hover, disabled and alignment styles that only matched `<a>` apply to
the buttons
- Unpinning an issue with the keyboard works, and removing a
non-permitted "blocked by" dependency sends the right type

Fixes: https://github.com/go-gitea/gitea/issues/40337

Assisted-by: Claude Code:claude-opus-5-5

---------

Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
authored and GitHub committed 2026-11-16 17:48:41 +00:00
1 parent 2f89c68b64
commit 8b48b45def
51 files changed
+162 -147

No files matched your search

+3
View File
@@ -44,6 +44,9 @@
}
.color-picker-combo .precolors .color {
border: none;
border-radius: 0;
padding: 0;
display: inline-block;
width: 15px;
height: 15px;
+17 -1
View File
@@ -22,18 +22,34 @@ Gitea's private styles use `g-` prefix.
text-overflow: ellipsis;
}
/* interact-xx classes can be used standalone, reset the <a> and <button> styles to default text styles */
.interact-fg, .interact-bg, .interact-link {
background: transparent;
border: none;
color: inherit;
cursor: pointer;
text-decoration: none;
text-align: left;
line-height: inherit;
margin: 0;
padding: 0;
}
.interact-fg { color: inherit !important; }
.interact-fg:hover { color: var(--color-primary) !important; }
.interact-fg:active { color: var(--color-primary-active) !important; }
.interact-fg.disabled:hover { color: inherit !important; }
.interact-bg { background: transparent !important; }
.interact-bg:hover { background: var(--color-hover) !important; }
.interact-bg:active { background: var(--color-active) !important; }
/* sometimes, we'd like to make "<button>" look like a link */
.interact-link { color: var(--color-primary); cursor: pointer; }
.interact-link { color: var(--color-primary); }
.interact-link:hover { text-decoration: underline; }
.interact-danger:hover { color: var(--color-danger) !important; }
/* primary-color dot centered on the top-right corner of the element */
.indicator-dot {
position: relative;
+2 -2
View File
@@ -13,8 +13,8 @@
}
.btn.is-loading > *,
.btn-octicon.is-loading > *,
.button.is-loading > * {
.button.is-loading > *,
button.is-loading > * {
opacity: 0;
}
+8
View File
@@ -2,6 +2,7 @@
cursor: pointer;
display: inline-flex;
align-items: center;
vertical-align: middle; /* align buttons with/without svg icon */
min-width: 0;
outline: none;
font-family: var(--fonts-regular);
@@ -50,6 +51,8 @@
color: var(--color-text);
}
button:disabled,
.btn:disabled,
.ui.buttons .disabled.button:not(.basic),
.ui.disabled.button,
.ui.button:disabled,
@@ -306,6 +309,11 @@
border: none;
}
.btn.disabled {
cursor: default;
opacity: var(--opacity-disabled);
}
/* sometimes, we'd like to make "<a href>" look like a button */
a.btn,
a.btn:hover {
+3
View File
@@ -95,6 +95,9 @@
padding: 9px 14px;
border-radius: var(--border-radius);
color: inherit;
border: none;
text-align: left;
line-height: inherit;
background: inherit;
text-decoration: none;
gap: 10px;
+1 -18
View File
@@ -153,25 +153,8 @@
font-size: 1em;
}
.non-diff-file-content .header .file-actions .btn-octicon {
line-height: var(--line-height-default);
.non-diff-file-content .header .file-actions .btn {
padding: 8px;
vertical-align: middle;
color: var(--color-text);
}
.non-diff-file-content .header .file-actions .btn-octicon:hover {
color: var(--color-primary);
}
.non-diff-file-content .header .file-actions .btn-octicon-danger:hover {
color: var(--color-red);
}
.non-diff-file-content .header .file-actions .btn-octicon.disabled {
color: inherit;
opacity: var(--opacity-disabled);
cursor: default;
}
.non-diff-file-content .plain-text {
+2
View File
@@ -50,6 +50,8 @@
.bottom-reactions .ui.label:not(.disabled):hover {
background: var(--color-reaction-hover-bg);
border-color: var(--color-secondary-dark-2);
color: var(--color-text);
}
.bottom-reactions .ui.label.disabled {