about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYamagishi Kazutoshi <ykzts@desire.sh>2017-06-03 21:40:24 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-06-03 14:40:24 +0200
commit3ea3f24a021254675ffc8472ee0cd7fdb54798ba (patch)
treee89b8f3e2b1bf08d3be4d38f9dab753fbd90aff2
parentd567a382e30b6d6f2b32dc249380e24b8d5f2be7 (diff)
Change toggle state when click label (#3530)
-rw-r--r--app/javascript/mastodon/features/notifications/components/setting_toggle.js12
-rw-r--r--app/javascript/styles/components.scss5
2 files changed, 8 insertions, 9 deletions
diff --git a/app/javascript/mastodon/features/notifications/components/setting_toggle.js b/app/javascript/mastodon/features/notifications/components/setting_toggle.js
index 6a42f7c75..a37abbd9c 100644
--- a/app/javascript/mastodon/features/notifications/components/setting_toggle.js
+++ b/app/javascript/mastodon/features/notifications/components/setting_toggle.js
@@ -10,7 +10,6 @@ class SettingToggle extends React.PureComponent {
     settingKey: PropTypes.array.isRequired,
     label: PropTypes.node.isRequired,
     onChange: PropTypes.func.isRequired,
-    htmlFor: PropTypes.string,
   }
 
   onChange = (e) => {
@@ -18,13 +17,14 @@ class SettingToggle extends React.PureComponent {
   }
 
   render () {
-    const { settings, settingKey, label, onChange, htmlFor = '' } = this.props;
+    const { settings, settingKey, label, onChange } = this.props;
+    const id = `setting-toggle-${settingKey.join('-')}`;
 
     return (
-      <label htmlFor={htmlFor} className='setting-toggle__label'>
-        <Toggle checked={settings.getIn(settingKey)} onChange={this.onChange} />
-        <span className='setting-toggle'>{label}</span>
-      </label>
+      <div className='setting-toggle'>
+        <Toggle id={id} checked={settings.getIn(settingKey)} onChange={this.onChange} />
+        <label htmlFor={id} className='setting-toggle__label'>{label}</label>
+      </div>
     );
   }
 
diff --git a/app/javascript/styles/components.scss b/app/javascript/styles/components.scss
index e396f04cc..a61705282 100644
--- a/app/javascript/styles/components.scss
+++ b/app/javascript/styles/components.scss
@@ -2172,13 +2172,12 @@ button.icon-button.active i.fa-retweet {
   left: 20px;
 }
 
-.setting-toggle__label {
+.setting-toggle {
   display: block;
   line-height: 24px;
-  vertical-align: middle;
 }
 
-.setting-toggle {
+.setting-toggle__label {
   color: $ui-primary-color;
   display: inline-block;
   margin-bottom: 14px;