Skip to content

Commit 1e8ff39

Browse files
authored
fix radio button positioning in webkit (#1157)
There is some weird interaction between the `text-align: center` on the parent `fieldset` element and the `position: absolute` of the child `input` element in Webkit. This could be a potential Webkit bug and I have tried to narrow down to a very specific scenario, as shown in this [jsfiddle](https://jsfiddle.net/q4L01uh9/7/). In the jsfiddle demo, it seems that the bug appears when the parent block element with `text-align: center` has both child block elements and child inline elements. In this scenario, the child inline elements with `position: absolute` would not be centered correctly. This fix bypass this potential bug by wrapping `<label>` and `<input>` in a div, because in this case the `position: absolute` of the `<input>` would be relative to the wrapping `<div>` instead of to the `<fieldset>`. Tested on WebkitGTK, Chrome and Firefox and it all works. Haven't tried Edge yet but I don't expect it to be any different from Chrome because it it based on Chromium. Possible related bug report for webkit: https://bugs.webkit.org/show_bug.cgi?id=31241
1 parent a7920ff commit 1e8ff39

File tree

2 files changed

+38
-30
lines changed

2 files changed

+38
-30
lines changed

lib/registries/addon/branded/new/styles.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@
9797
text-transform: uppercase;
9898
}
9999

100+
.RadioButtonAndLabelDiv {
101+
display: inline;
102+
}
103+
100104
.IsChecked {
101105
color: $color-osf-secondary;
102106
background-color: $color-bg-gray-blue-light;

lib/registries/addon/branded/new/template.hbs

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28,36 +28,40 @@
2828
<legend local-class='RadioLegend'>
2929
{{t 'registries.new.step_one_project_heading'}}
3030
</legend>
31-
<input
32-
data-test-has-project-button
33-
local-class='RadioElement RadioInput'
34-
type='radio'
35-
name='HasProject'
36-
value='yes'
37-
onclick={{fn (mut this.isBasedOnProject) true}}
38-
checked={{this.isBasedOnProject}}
39-
>
40-
<label
41-
local-class='RadioElement RadioLabel {{if this.isBasedOnProject 'IsChecked'}}'
42-
for='HasProject'
43-
>
44-
{{t 'registries.new.yes'}}
45-
</label>
46-
<input
47-
data-test-no-project-button
48-
local-class='RadioElement RadioInput'
49-
type='radio'
50-
name='no-project'
51-
value='no'
52-
onclick={{fn (mut this.isBasedOnProject) false}}
53-
checked={{not this.isBasedOnProject}}
54-
>
55-
<label
56-
local-class='RadioElement RadioLabel {{unless this.isBasedOnProject 'IsChecked'}}'
57-
for='NoProject'
58-
>
59-
{{t 'registries.new.no'}}
60-
</label>
31+
<div local-class='RadioButtonAndLabelDiv'>
32+
<input
33+
data-test-has-project-button
34+
local-class='RadioElement RadioInput'
35+
type='radio'
36+
name='HasProject'
37+
value='yes'
38+
onclick={{fn (mut this.isBasedOnProject) true}}
39+
checked={{this.isBasedOnProject}}
40+
>
41+
<label
42+
local-class='RadioElement RadioLabel {{if this.isBasedOnProject 'IsChecked'}}'
43+
for='HasProject'
44+
>
45+
{{t 'registries.new.yes'}}
46+
</label>
47+
</div>
48+
<div local-class='RadioButtonAndLabelDiv'>
49+
<input
50+
data-test-no-project-button
51+
local-class='RadioElement RadioInput'
52+
type='radio'
53+
name='no-project'
54+
value='no'
55+
onclick={{fn (mut this.isBasedOnProject) false}}
56+
checked={{not this.isBasedOnProject}}
57+
>
58+
<label
59+
local-class='RadioElement RadioLabel {{unless this.isBasedOnProject 'IsChecked'}}'
60+
for='NoProject'
61+
>
62+
{{t 'registries.new.no'}}
63+
</label>
64+
</div>
6165
</fieldset>
6266
</label>
6367
{{#if this.isBasedOnProject}}

0 commit comments

Comments
 (0)