Skip to content

Commit 3d92ad8

Browse files
authored
Use native inputs in whitespace dropdown (#20980)
Use native `<input type="radio">` instead of fake icon font. The `pointer-events: none` is necessary so the link click always takes effect. Tested in Firefox, Safari and Chrome. Before: <img width="305" alt="Screen Shot 2022-08-27 at 20 42 11" src="https://user-images.githubusercontent.com/115237/187044786-6655c766-c3fb-4672-9e3e-219b3ec4896c.png"> After: <img width="298" alt="Screen Shot 2022-08-27 at 21 10 05" src="https://user-images.githubusercontent.com/115237/187044790-33f87741-062e-4744-80b1-d3bd3fd725e3.png"> <img width="302" alt="image" src="https://user-images.githubusercontent.com/115237/187044872-6c133cea-65ee-4ebd-b18a-a8b38c791565.png">
1 parent c4742fb commit 3d92ad8

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

templates/repo/diff/whitespace_dropdown.tmpl

+16-8
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,28 @@
33
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
44
<div class="menu">
55
<a class="item" href="?style={{if .IsSplitStyle}}split{{else}}unified{{end}}&whitespace=show-all">
6-
<i class="circle {{if eq .WhitespaceBehavior "show-all"}}dot{{else}}outline{{end}} icon"></i>
7-
{{.locale.Tr "repo.diff.whitespace_show_everything"}}
6+
<label class="pointer-events-none">
7+
<input class="mr-3 pointer-events-none" type="radio"{{if eq .WhitespaceBehavior "show-all"}} checked{{end}}>
8+
{{.locale.Tr "repo.diff.whitespace_show_everything"}}
9+
</label>
810
</a>
911
<a class="item" href="?style={{if .IsSplitStyle}}split{{else}}unified{{end}}&whitespace=ignore-all">
10-
<i class="circle {{if eq .WhitespaceBehavior "ignore-all"}}dot{{else}}outline{{end}} icon"></i>
11-
{{.locale.Tr "repo.diff.whitespace_ignore_all_whitespace"}}
12+
<label class="pointer-events-none">
13+
<input class="mr-3 pointer-events-none" type="radio"{{if eq .WhitespaceBehavior "ignore-all"}} checked{{end}}>
14+
{{.locale.Tr "repo.diff.whitespace_ignore_all_whitespace"}}
15+
<label>
1216
</a>
1317
<a class="item" href="?style={{if .IsSplitStyle}}split{{else}}unified{{end}}&whitespace=ignore-change">
14-
<i class="circle {{if eq .WhitespaceBehavior "ignore-change"}}dot{{else}}outline{{end}} icon"></i>
15-
{{.locale.Tr "repo.diff.whitespace_ignore_amount_changes"}}
18+
<label class="pointer-events-none">
19+
<input class="mr-3 pointer-events-none" type="radio"{{if eq .WhitespaceBehavior "ignore-change"}} checked{{end}}>
20+
{{.locale.Tr "repo.diff.whitespace_ignore_amount_changes"}}
21+
</label>
1622
</a>
1723
<a class="item" href="?style={{if .IsSplitStyle}}split{{else}}unified{{end}}&whitespace=ignore-eol">
18-
<i class="circle {{if eq .WhitespaceBehavior "ignore-eol"}}dot{{else}}outline{{end}} icon"></i>
19-
{{.locale.Tr "repo.diff.whitespace_ignore_at_eol"}}
24+
<label class="pointer-events-none">
25+
<input class="mr-3 pointer-events-none" type="radio"{{if eq .WhitespaceBehavior "ignore-eol"}} checked{{end}}>
26+
{{.locale.Tr "repo.diff.whitespace_ignore_at_eol"}}
27+
</label>
2028
</a>
2129
</div>
2230
</div>

web_src/less/helpers.less

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
.h-100 { height: 100% !important; }
2020
.br-0 { border-radius: 0 !important; }
2121

22+
/* below class names match Tailwind CSS */
23+
.pointer-events-none { pointer-events: none !important; }
24+
2225
.mono {
2326
font-family: var(--fonts-monospace) !important;
2427
font-size: .9em !important; /* compensate for monospace fonts being usually slightly larger */

0 commit comments

Comments
 (0)