Skip to content
This repository was archived by the owner on Dec 11, 2019. It is now read-only.

Commit f7778d7

Browse files
committed
SwitchControl text to left, right or top of control now toggles checked state
Partial resolution for #8243 since many usages do not use the built-in text but render their own text separately. A subsequent commit will address converting these usages. This also converts text from span to label for accessbility and more appropriate renderer defaults (the cursor).
1 parent 2f9ef72 commit f7778d7

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

app/renderer/components/common/switchControl.js

+12-9
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,19 @@ class SwitchControl extends ImmutableComponent {
3636
>
3737
{
3838
this.props.leftl10nId && this.props.topl10nId
39-
? <div className='switchControlText'><div className='switchControlLeftText'><div className='switchSpacer'>&nbsp;</div><span className='switchControlLeftText' data-l10n-id={this.props.leftl10nId} /></div></div>
39+
? <div className='switchControlText'><div className='switchControlLeftText'><div className='switchSpacer'>&nbsp;</div><label className='switchControlLeftText' onClick={this.onClick} data-l10n-id={this.props.leftl10nId} /></div></div>
4040
: (this.props.leftl10nId
41-
? <span className='switchControlLeftText' data-l10n-id={this.props.leftl10nId} />
41+
? <label className='switchControlLeftText' onClick={this.onClick} data-l10n-id={this.props.leftl10nId} />
4242
: null)
4343
}
4444
<div className='switchMiddle'>
4545
{
4646
this.props.topl10nId
47-
? <span className={cx({
47+
? <label className={cx({
4848
switchControlTopText: true,
4949
[this.props.customTopTextClassName]: !!this.props.customTopTextClassName
5050
})}
51+
onClick={this.onClick}
5152
data-l10n-id={this.props.topl10nId} />
5253
: null
5354
}
@@ -67,34 +68,36 @@ class SwitchControl extends ImmutableComponent {
6768
? <div className='switchControlText'>
6869
<div className='switchControlRightText'>
6970
<div className='switchSpacer'>&nbsp;</div>
70-
<span className={cx({
71+
<label className={cx({
7172
switchControlRightText: true,
7273
[this.props.customRightTextClassName]: !!this.props.customRightTextClassName
7374
})}
75+
onClick={this.onClick}
7476
data-l10n-id={this.props.rightl10nId}
7577
data-l10n-args={this.props.rightl10nArgs}
76-
>{this.props.rightText || ''}</span>
78+
>{this.props.rightText || ''}</label>
7779
</div>
7880
</div>
7981
: <div className='switchControlRight'>
8082
{
8183
(this.props.rightl10nId || this.props.rightText) && !this.props.onInfoClick
82-
? <span className={cx({
84+
? <label className={cx({
8385
switchControlRightText: true,
8486
[this.props.customRightTextClassName]: !!this.props.customRightTextClassName
8587
})}
88+
onClick={this.onClick}
8689
data-l10n-id={this.props.rightl10nId}
8790
data-l10n-args={this.props.rightl10nArgs}
88-
>{this.props.rightText || ''}</span>
91+
>{this.props.rightText || ''}</label>
8992
: null
9093
}
9194
{
9295
(this.props.rightl10nId || this.props.rightText) && this.props.onInfoClick
9396
? <div className='switchControlRightText'>
94-
<span data-l10n-id={this.props.rightl10nId}
97+
<label onClick={this.onClick} data-l10n-id={this.props.rightl10nId}
9598
data-l10n-args={this.props.rightl10nArgs}>
9699
{this.props.rightText}
97-
</span>
100+
</label>
98101
<span className={cx({
99102
fa: true,
100103
'fa-question-circle': true,

0 commit comments

Comments
 (0)