From 8cc1ed3c556830092601425881384f8667dec437 Mon Sep 17 00:00:00 2001 From: Surinna Curtis Date: Sat, 2 Sep 2017 09:27:16 -0500 Subject: [PATCH] Don't unconditionally call `preventDefault` and `stopPropagation` on all keyup events (#4777) * 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 --- .../features/notifications/components/setting_toggle.js | 6 ------ .../mastodon/features/ui/components/upload_area.js | 5 ++--- 2 files changed, 2 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 a20e7ca51..281359d2a 100644 --- a/app/javascript/mastodon/features/notifications/components/setting_toggle.js +++ b/app/javascript/mastodon/features/notifications/components/setting_toggle.js @@ -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('-'); diff --git a/app/javascript/mastodon/features/ui/components/upload_area.js b/app/javascript/mastodon/features/ui/components/upload_area.js index 030c3db2e..dda28feeb 100644 --- a/app/javascript/mastodon/features/ui/components/upload_area.js +++ b/app/javascript/mastodon/features/ui/components/upload_area.js @@ -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; }