Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Dropdown): add a11y prop to tab moves focus #1600

Merged
merged 1 commit into from Oct 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/lib/Components/DropdownsPage.js
Expand Up @@ -57,6 +57,7 @@ export default class DropdownPage extends React.Component {
<pre>
<PrismCode className="language-jsx">
{`Dropdown.propTypes = {
a11y: PropTypes.bool, // defaults to true. Set to false to enable more bootstrap like tabbing behavior
disabled: PropTypes.bool,
direction: PropTypes.oneOf(['up', 'down', 'left', 'right']),
group: PropTypes.bool,
Expand Down
4 changes: 3 additions & 1 deletion src/Dropdown.js
Expand Up @@ -9,6 +9,7 @@ import { DropdownContext } from './DropdownContext';
import { mapToCssModules, omit, keyCodes, tagPropType } from './utils';

const propTypes = {
a11y: PropTypes.bool,
disabled: PropTypes.bool,
direction: PropTypes.oneOf(['up', 'down', 'left', 'right']),
group: PropTypes.bool,
Expand All @@ -27,6 +28,7 @@ const propTypes = {
};

const defaultProps = {
a11y: true,
isOpen: false,
direction: 'down',
nav: false,
Expand Down Expand Up @@ -114,7 +116,7 @@ class Dropdown extends React.Component {
handleKeyDown(e) {
if (
/input|textarea/i.test(e.target.tagName)
|| (keyCodes.tab === e.which && e.target.getAttribute('role') !== 'menuitem')
|| (keyCodes.tab === e.which && (e.target.getAttribute('role') !== 'menuitem' || !this.props.a11y))
) {
return;
}
Expand Down