Skip to content

Commit

Permalink
fix(Dropdown): Do not focus Dropdown if menu is not opened (patternfl…
Browse files Browse the repository at this point in the history
  • Loading branch information
karelhala authored and jschuler committed Jan 21, 2019
1 parent 1a6d3e1 commit 45367bc
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class DropdownToggle extends Component {
};

onDocClick = event => {
if (this.props.parentRef && !this.props.parentRef.contains(event.target)) {
if (this.props.isOpen && this.props.parentRef && !this.props.parentRef.contains(event.target)) {
this.props.onToggle && this.props.onToggle(false);
this.toggle.focus();
}
Expand All @@ -64,7 +64,7 @@ class DropdownToggle extends Component {
onEscPress = event => {
const { parentRef } = this.props;
const keyCode = event.keyCode || event.which;
if ((keyCode === KEY_CODES.ESCAPE_KEY || event.key === 'Tab') && parentRef && parentRef.contains(event.target)) {
if (this.props.isOpen && (keyCode === KEY_CODES.ESCAPE_KEY || event.key === 'Tab') && parentRef && parentRef.contains(event.target)) {
this.props.onToggle && this.props.onToggle(false);
this.toggle.focus();
}
Expand Down

0 comments on commit 45367bc

Please sign in to comment.