Skip to content

Commit

Permalink
feat: support focusFirstItemOnShow prop on Dropdowns
Browse files Browse the repository at this point in the history
  • Loading branch information
jquense committed Mar 7, 2019
1 parent d29f615 commit c614940
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ const propTypes = {
*/
onSelect: PropTypes.func,

/**
* Controls the focus behavior for when the Dropdown is opened. Set to
* `true` to always focus the first menu item, `keyboard` to focus only when
* navigating via the keyboard, or `false` to disable completely
*
* The Default behavior is `false` **unless** the Menu has a `role="menu"`
* where it will default to `keyboard` to match the recommended [ARIA Authoring practices](https://www.w3.org/TR/wai-aria-practices-1.1/#menubutton).
*/
focusFirstItemOnShow: PropTypes.oneOf([false, true, 'keyboard']),

/** @private */
navbar: PropTypes.bool,
};
Expand Down Expand Up @@ -97,8 +107,9 @@ class Dropdown extends React.Component {
drop,
show,
className,
as: Component,
alignRight,
focusFirstItemOnShow,
as: Component,
onSelect: _1,
onToggle: _3,
navbar: _4,
Expand All @@ -114,6 +125,7 @@ class Dropdown extends React.Component {
show={show}
alignEnd={alignRight}
onToggle={this.handleToggle}
focusFirstItemOnShow={focusFirstItemOnShow}
itemSelector={`.${bsPrefix}-item:not(.disabled):not(:disabled)`}
>
{({ props: dropdownProps }) => (
Expand Down

0 comments on commit c614940

Please sign in to comment.