From 79fc14b2e34a7b30322549b0dbb80083b982f320 Mon Sep 17 00:00:00 2001 From: Gregory McLean Date: Mon, 13 Jan 2020 18:39:34 -0400 Subject: [PATCH] fix(uishell): close HeaderMenu on blur (#5003) --- packages/react/src/components/UIShell/HeaderMenu.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/react/src/components/UIShell/HeaderMenu.js b/packages/react/src/components/UIShell/HeaderMenu.js index 1acad38bd074..d9e83c75165a 100644 --- a/packages/react/src/components/UIShell/HeaderMenu.js +++ b/packages/react/src/components/UIShell/HeaderMenu.js @@ -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 }); }; /**