Skip to content

Commit

Permalink
fix(uishell): close HeaderMenu on blur (#5003)
Browse files Browse the repository at this point in the history
  • Loading branch information
GregDevProjects authored and joshblack committed Jan 23, 2020
1 parent 239b66d commit 79fc14b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/react/src/components/UIShell/HeaderMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,18 @@ class HeaderMenu extends React.Component {
handleOnBlur = event => {
// Rough guess for a blur event that is triggered outside of our menu or
// menubar context
if (!event.relatedTarget) {
this.setState({ expanded: false, selectedIndex: null });
const itemTriggeredBlur = this.items.find(
element => element === event.relatedTarget
);

if (
event.relatedTarget &&
(event.relatedTarget.getAttribute('href') !== '#' || itemTriggeredBlur)
) {
return;
}

this.setState({ expanded: false, selectedIndex: null });
};

/**
Expand Down

0 comments on commit 79fc14b

Please sign in to comment.