Skip to content

Commit

Permalink
fix(Dropdown): handle on enter focusing when options are disabled (#2025
Browse files Browse the repository at this point in the history
)
  • Loading branch information
kmcfaul authored and tlabaj committed May 17, 2019
1 parent a25c4bf commit 8903702
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,14 @@ class DropdownMenu extends React.Component {

componentDidMount() {
if (this.props.openedOnEnter) {
if (this.props.component === 'ul') this.refsCollection[0].focus();
const focusTarget =
this.refsCollection.filter(
ref => ref && ((ref.current && !ref.current.hasAttribute('disabled')) || !ref.hasAttribute('disabled'))
)[0] || null;
if (this.props.component === 'ul') focusTarget && focusTarget.focus();
else {
(this.refsCollection[0].current.focus && this.refsCollection[0].current.focus()) ||
ReactDOM.findDOMNode(this.refsCollection[0].current).focus();
(focusTarget.current.focus && focusTarget.current.focus()) ||
(focusTarget && ReactDOM.findDOMNode(focusTarget.current).focus());
}
}
}
Expand Down

0 comments on commit 8903702

Please sign in to comment.