Skip to content

Commit d473de0

Browse files
Make add line comment buttons focusable (#25894)
Use a real button and add an aria-label. Additionally, show the button whenever it is focused. See https://codeberg.org/forgejo/forgejo/issues/998 for explanation. Our handling of this button is now equal to that of GitHub. Nothing has changed visually.
1 parent 9672085 commit d473de0

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2375,6 +2375,7 @@ diff.show_more = Show More
23752375
diff.load = Load Diff
23762376
diff.generated = generated
23772377
diff.vendored = vendored
2378+
diff.comment.add_line_comment = Add line comment
23782379
diff.comment.placeholder = Leave a comment
23792380
diff.comment.markdown_info = Styling with markdown is supported.
23802381
diff.comment.add_single_comment = Add single comment

templates/repo/diff/section_split.tmpl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
<td class="lines-type-marker lines-type-marker-old del-code"><span class="gt-mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span></td>
4848
<td class="lines-code lines-code-old del-code">{{/*
4949
*/}}{{if and $.root.SignedUserID $.root.PageIsPullFiles}}{{/*
50-
*/}}<a class="ui primary button add-code-comment add-code-comment-left{{if (not $line.CanComment)}} invisible{{end}}" data-side="left" data-idx="{{$line.LeftIdx}}">{{/*
50+
*/}}<button type="button" aria-label="{{$.root.locale.Tr "repo.diff.comment.add_line_comment"}}" class="ui primary button add-code-comment add-code-comment-left{{if (not $line.CanComment)}} invisible{{end}}" data-side="left" data-idx="{{$line.LeftIdx}}">{{/*
5151
*/}}{{svg "octicon-plus"}}{{/*
52-
*/}}</a>{{/*
52+
*/}}</button>{{/*
5353
*/}}{{end}}{{/*
5454
*/}}{{if $line.LeftIdx}}{{/*
5555
*/}}{{template "repo/diff/section_code" dict "diff" $leftDiff "locale" $.root.locale}}{{/*
@@ -62,9 +62,9 @@
6262
<td class="lines-type-marker lines-type-marker-new add-code">{{if $match.RightIdx}}<span class="gt-mono" data-type-marker="{{$match.GetLineTypeMarker}}"></span>{{end}}</td>
6363
<td class="lines-code lines-code-new add-code">{{/*
6464
*/}}{{if and $.root.SignedUserID $.root.PageIsPullFiles}}{{/*
65-
*/}}<a class="ui primary button add-code-comment add-code-comment-right{{if (not $match.CanComment)}} invisible{{end}}" data-side="right" data-idx="{{$match.RightIdx}}">{{/*
65+
*/}}<button type="button" aria-label="{{$.root.locale.Tr "repo.diff.comment.add_line_comment"}}" class="ui primary button add-code-comment add-code-comment-right{{if (not $match.CanComment)}} invisible{{end}}" data-side="right" data-idx="{{$match.RightIdx}}">{{/*
6666
*/}}{{svg "octicon-plus"}}{{/*
67-
*/}}</a>{{/*
67+
*/}}</button>{{/*
6868
*/}}{{end}}{{/*
6969
*/}}{{if $match.RightIdx}}{{/*
7070
*/}}{{template "repo/diff/section_code" dict "diff" $rightDiff "locale" $.root.locale}}{{/*
@@ -79,9 +79,9 @@
7979
<td class="lines-type-marker lines-type-marker-old">{{if $line.LeftIdx}}<span class="gt-mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span>{{end}}</td>
8080
<td class="lines-code lines-code-old">{{/*
8181
*/}}{{if and $.root.SignedUserID $.root.PageIsPullFiles (not (eq .GetType 2))}}{{/*
82-
*/}}<a class="ui primary button add-code-comment add-code-comment-left{{if (not $line.CanComment)}} invisible{{end}}" data-side="left" data-idx="{{$line.LeftIdx}}">{{/*
82+
*/}}<button type="button" aria-label="{{$.root.locale.Tr "repo.diff.comment.add_line_comment"}}" class="ui primary button add-code-comment add-code-comment-left{{if (not $line.CanComment)}} invisible{{end}}" data-side="left" data-idx="{{$line.LeftIdx}}">{{/*
8383
*/}}{{svg "octicon-plus"}}{{/*
84-
*/}}</a>{{/*
84+
*/}}</button>{{/*
8585
*/}}{{end}}{{/*
8686
*/}}{{if $line.LeftIdx}}{{/*
8787
*/}}{{template "repo/diff/section_code" dict "diff" $inlineDiff "locale" $.root.locale}}{{/*
@@ -94,9 +94,9 @@
9494
<td class="lines-type-marker lines-type-marker-new">{{if $line.RightIdx}}<span class="gt-mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span>{{end}}</td>
9595
<td class="lines-code lines-code-new">{{/*
9696
*/}}{{if and $.root.SignedUserID $.root.PageIsPullFiles (not (eq .GetType 3))}}{{/*
97-
*/}}<a class="ui primary button add-code-comment add-code-comment-right{{if (not $line.CanComment)}} invisible{{end}}" data-side="right" data-idx="{{$line.RightIdx}}">{{/*
97+
*/}}<button type="button" aria-label="{{$.root.locale.Tr "repo.diff.comment.add_line_comment"}}" class="ui primary button add-code-comment add-code-comment-right{{if (not $line.CanComment)}} invisible{{end}}" data-side="right" data-idx="{{$line.RightIdx}}">{{/*
9898
*/}}{{svg "octicon-plus"}}{{/*
99-
*/}}</a>{{/*
99+
*/}}</button>{{/*
100100
*/}}{{end}}{{/*
101101
*/}}{{if $line.RightIdx}}{{/*
102102
*/}}{{template "repo/diff/section_code" dict "diff" $inlineDiff "locale" $.root.locale}}{{/*

templates/repo/diff/section_unified.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@
5252
{{else}}
5353
<td class="chroma lines-code{{if (not $line.RightIdx)}} lines-code-old{{end}}">{{/*
5454
*/}}{{if and $.root.SignedUserID $.root.PageIsPullFiles}}{{/*
55-
*/}}<a class="ui primary button add-code-comment add-code-comment-{{if $line.RightIdx}}right{{else}}left{{end}}{{if (not $line.CanComment)}} invisible{{end}}" data-side="{{if $line.RightIdx}}right{{else}}left{{end}}" data-idx="{{if $line.RightIdx}}{{$line.RightIdx}}{{else}}{{$line.LeftIdx}}{{end}}">{{/*
55+
*/}}<button type="button" aria-label="{{$.root.locale.Tr "repo.diff.comment.add_line_comment"}}" class="ui primary button add-code-comment add-code-comment-{{if $line.RightIdx}}right{{else}}left{{end}}{{if (not $line.CanComment)}} invisible{{end}}" data-side="{{if $line.RightIdx}}right{{else}}left{{end}}" data-idx="{{if $line.RightIdx}}{{$line.RightIdx}}{{else}}{{$line.LeftIdx}}{{end}}">{{/*
5656
*/}}{{svg "octicon-plus"}}{{/*
57-
*/}}</a>{{/*
57+
*/}}</button>{{/*
5858
*/}}{{end}}{{/*
5959
*/}}{{template "repo/diff/section_code" dict "diff" $inlineDiff "locale" $.root.locale}}{{/*
6060
*/}}</td>

web_src/css/review.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
opacity: 1;
3737
}
3838

39+
.ui.button.add-code-comment:focus {
40+
opacity: 1;
41+
}
42+
3943
.repository .diff-file-box .code-diff .add-comment-left,
4044
.repository .diff-file-box .code-diff .add-comment-right,
4145
.repository .diff-file-box .code-diff .add-code-comment .add-comment-left,

0 commit comments

Comments
 (0)