]> cat aescling's git repositories - mastodon.git/commitdiff
Don't unconditionally call `preventDefault` and `stopPropagation` on all keyup events...
authorSurinna Curtis <ekiru.0@gmail.com>
Sat, 2 Sep 2017 14:27:16 +0000 (09:27 -0500)
committerEugen Rochko <eugen@zeonfederated.com>
Sat, 2 Sep 2017 14:27:16 +0000 (16:27 +0200)
* UploadArea should only preventDefault for Escape

This will make accessibility for some things less effortful, since we won't have to define a prior event handler to do whatever should be happening by default.

* Remove workaround for fixed bug in SettingToggle

SettingToggle was toggling itself in response to keydown of space, and then the keyup was doing it again

app/javascript/mastodon/features/notifications/components/setting_toggle.js
app/javascript/mastodon/features/ui/components/upload_area.js

index a20e7ca5173f1f977d82ebdcb9ddb076241652fa..281359d2a26b007ec91a704e0f1c6c4b207c5e87 100644 (file)
@@ -18,12 +18,6 @@ export default class SettingToggle extends React.PureComponent {
     this.props.onChange(this.props.settingKey, target.checked);
   }
 
-  onKeyDown = e => {
-    if (e.key === ' ') {
-      this.props.onChange(this.props.settingKey, !e.target.checked);
-    }
-  }
-
   render () {
     const { prefix, settings, settingKey, label, meta } = this.props;
     const id = ['setting-toggle', prefix, ...settingKey].filter(Boolean).join('-');
index 030c3db2efe0dbe9171404791eb499578b58a746..dda28feeb74096e8595f112245d0ff53f5657902 100644 (file)
@@ -12,13 +12,12 @@ export default class UploadArea extends React.PureComponent {
   };
 
   handleKeyUp = (e) => {
-    e.preventDefault();
-    e.stopPropagation();
-
     const keyCode = e.keyCode;
     if (this.props.active) {
       switch(keyCode) {
       case 27:
+        e.preventDefault();
+        e.stopPropagation();
         this.props.onClose();
         break;
       }