From 3ddfab69a5b8b7fec2350402368c68f7ae728341 Mon Sep 17 00:00:00 2001 From: Sorin Davidoi Date: Fri, 28 Jul 2017 04:37:30 +0200 Subject: [PATCH] Improve accessibility (part 4) (#4408) * fix(dropdown_menu): Keyboard navigation * fix(icon_button): Add aria-pressed attribute * fix(privacy_dropdown): Make accessible * fix(emoji_picker_dropdown): Make accessible * fix(icon_button): Support tabIndex * fix(actions_modal): Remove icon from tab order * fix(dropdown_menu): Add role=group * fix(setting_toggle): Toggle via space key * fix(dropdown_menu): Remove redundant handling of Space key * fix(emoji_picker_dropdown): Remove redundant Space key handling * fix(privacy_dropdown): Remove redundant Space key handling * fix(status): Switch to article and add aria-posinset, aria-setsize * fix(status_list): Use role=feed and pass more ARIA props to Status * chore(eslint): jsx-a11y/role-supports-aria-props --- .eslintrc.yml | 2 +- .../mastodon/components/dropdown_menu.js | 22 ++++++++++++++---- .../mastodon/components/icon_button.js | 5 ++++ app/javascript/mastodon/components/status.js | 21 +++++++++-------- .../mastodon/components/status_list.js | 6 ++--- .../components/emoji_picker_dropdown.js | 23 ++++++++++++++++--- .../compose/components/privacy_dropdown.js | 16 ++++++++----- .../components/setting_toggle.js | 8 ++++++- .../features/ui/components/actions_modal.js | 2 +- 9 files changed, 76 insertions(+), 29 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index 2c264351ec..fd2ba46dd0 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -121,6 +121,6 @@ rules: jsx-a11y/onclick-has-focus: warn jsx-a11y/onclick-has-role: warn jsx-a11y/role-has-required-aria-props: warn - jsx-a11y/role-supports-aria-props: warn + jsx-a11y/role-supports-aria-props: off jsx-a11y/scope: warn jsx-a11y/tabindex-no-positive: warn diff --git a/app/javascript/mastodon/components/dropdown_menu.js b/app/javascript/mastodon/components/dropdown_menu.js index 8e9e6ab94a..f62a75183a 100644 --- a/app/javascript/mastodon/components/dropdown_menu.js +++ b/app/javascript/mastodon/components/dropdown_menu.js @@ -74,6 +74,18 @@ export default class DropdownMenu extends React.PureComponent { handleHide = () => this.setState({ expanded: false }) + handleToggle = (e) => { + if (e.key === 'Enter') { + if (this.props.isUserTouching()) { + this.handleShow(); + } else { + this.setState({ expanded: !this.state.expanded }); + } + } else if (e.key === 'Escape') { + this.setState({ expanded: false }); + } + } + renderItem = (item, i) => { if (item === null) { return
  • ; @@ -83,7 +95,7 @@ export default class DropdownMenu extends React.PureComponent { return (
  • - + {text}
  • @@ -107,7 +119,7 @@ export default class DropdownMenu extends React.PureComponent { } const dropdownItems = expanded && ( -