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

fix(uishell): close HeaderMenu on blur #5003

Merged
merged 8 commits into from
Jan 13, 2020
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