Skip to content

Commit 525b738

Browse files
authored
Convert issue list checkboxes to native (#23596)
Use native instead of fomantic checkboxes in issue list. Benefits include no more JS pop-in on load and perfect a11y. Before, with JS pop-in: <img width="92" alt="Screenshot 2023-03-20 at 17 02 02" src="https://user-images.githubusercontent.com/115237/226398955-99029a1c-1150-449c-821b-e4165e7446a8.png"> After, Firefox on macOS: <img width="126" alt="Screenshot 2023-03-20 at 17 01 26" src="https://user-images.githubusercontent.com/115237/226399018-58df2c32-c2b2-4c78-b7df-7b76523abe21.png"> After, Chrome on macOS: <img width="79" alt="Screenshot 2023-03-20 at 17 01 42" src="https://user-images.githubusercontent.com/115237/226399074-947e6279-8dc3-42c2-90b5-b106c471b23d.png"> I opted to not do styling yet but I see that the inconsistency between browsers may already be reason enough on doing it. I think if we style them, there should be one global style, including markdown ones which currently have custom styling.
1 parent 964a057 commit 525b738

File tree

5 files changed

+8
-29
lines changed

5 files changed

+8
-29
lines changed

templates/repo/issue/list.tmpl

+1-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@
2929
<div id="issue-filters" class="ui stackable grid">
3030
<div class="six wide column">
3131
{{if $.CanWriteIssuesOrPulls}}
32-
<div class="ui checkbox issue-checkbox-all gt-vm">
33-
<input type="checkbox" title="{{.locale.Tr "repo.issues.action_check_all"}}">
34-
</div>
32+
<input type="checkbox" autocomplete="off" class="issue-checkbox-all gt-vm gt-mr-4" title="{{.locale.Tr "repo.issues.action_check_all"}}">
3533
{{end}}
3634
{{template "repo/issue/openclose" .}}
3735
</div>

templates/shared/issuelist.tmpl

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
{{$approvalCounts := .ApprovalCounts}}
33
{{range .Issues}}
44
<li class="item gt-df gt-py-3">
5-
<div class="issue-item-left gt-df">
5+
<div class="issue-item-left gt-df gt-items-start">
66
{{if $.CanWriteIssuesOrPulls}}
7-
<div class="ui checkbox issue-checkbox">
8-
<input type="checkbox" data-issue-id={{.ID}} title="{{$.locale.Tr "repo.issues.action_check"}} «{{.Title}}»">
9-
</div>
7+
<input type="checkbox" autocomplete="off" class="issue-checkbox gt-mt-2 gt-mr-4" data-issue-id={{.ID}} aria-label="{{$.locale.Tr "repo.issues.action_check"}} &quot;{{.Title}}&quot;">
108
{{end}}
119
<div class="issue-item-icon">
1210
{{if .IsPull}}

web_src/css/helpers.css

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
.gt-relative { position: relative !important; }
2525
.gt-overflow-x-scroll { overflow-x: scroll !important; }
2626
.gt-cursor-default { cursor: default !important; }
27+
.gt-items-start { align-items: flex-start !important; }
2728

2829
.gt-mono {
2930
font-family: var(--fonts-monospace) !important;

web_src/css/shared/issuelist.css

-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
color: var(--color-primary) !important;
88
}
99

10-
.issue.list > .item .issue-checkbox {
11-
margin-top: 1px;
12-
}
13-
1410
.issue.list > .item .issue-item-icon svg {
1511
margin-right: 0.75rem;
1612
margin-top: 1px;

web_src/js/features/common-issue.js

+4-18
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ import {updateIssuesMeta} from './repo-issue.js';
33
import {toggleElem} from '../utils/dom.js';
44

55
export function initCommonIssue() {
6-
const $issueSelectAllWrapper = $('.issue-checkbox-all');
7-
const $issueSelectAll = $('.issue-checkbox-all input');
8-
const $issueCheckboxes = $('.issue-checkbox input');
6+
const $issueSelectAll = $('.issue-checkbox-all');
7+
const $issueCheckboxes = $('.issue-checkbox');
98

109
const syncIssueSelectionState = () => {
1110
const $checked = $issueCheckboxes.filter(':checked');
@@ -23,7 +22,7 @@ export function initCommonIssue() {
2322
toggleElem($('#issue-filters'), !anyChecked);
2423
toggleElem($('#issue-actions'), anyChecked);
2524
// there are two panels but only one select-all checkbox, so move the checkbox to the visible panel
26-
$('#issue-filters, #issue-actions').filter(':visible').find('.column:first').prepend($issueSelectAllWrapper);
25+
$('#issue-filters, #issue-actions').filter(':visible').find('.column:first').prepend($issueSelectAll);
2726
};
2827

2928
$issueCheckboxes.on('change', syncIssueSelectionState);
@@ -38,7 +37,7 @@ export function initCommonIssue() {
3837
let action = this.getAttribute('data-action');
3938
let elementId = this.getAttribute('data-element-id');
4039
const url = this.getAttribute('data-url');
41-
const issueIDs = $('.issue-checkbox').children('input:checked').map((_, el) => {
40+
const issueIDs = $('.issue-checkbox:checked').map((_, el) => {
4241
return el.getAttribute('data-issue-id');
4342
}).get().join(',');
4443
if (elementId === '0' && url.slice(-9) === '/assignee') {
@@ -54,20 +53,7 @@ export function initCommonIssue() {
5453
issueIDs,
5554
elementId
5655
).then(() => {
57-
// NOTICE: This reset of checkbox state targets Firefox caching behaviour, as the
58-
// checkboxes stay checked after reload
59-
if (action === 'close' || action === 'open') {
60-
// uncheck all checkboxes
61-
$('.issue-checkbox input[type="checkbox"]').each((_, e) => { e.checked = false });
62-
}
6356
window.location.reload();
6457
});
6558
});
66-
67-
// NOTICE: This event trigger targets Firefox caching behaviour, as the checkboxes stay
68-
// checked after reload trigger checked event, if checkboxes are checked on load
69-
$('.issue-checkbox input[type="checkbox"]:checked').first().each((_, e) => {
70-
e.checked = false;
71-
$(e).trigger('click');
72-
});
7359
}

0 commit comments

Comments
 (0)