From 771f132b5a8a084708207f7c83a2cd8701875a76 Mon Sep 17 00:00:00 2001 From: Greg McLean Date: Fri, 10 Jan 2020 11:04:13 -0400 Subject: [PATCH 1/2] fix(uishell): close HeaderMenu on blur --- packages/react/src/components/UIShell/HeaderMenu.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/react/src/components/UIShell/HeaderMenu.js b/packages/react/src/components/UIShell/HeaderMenu.js index 1acad38bd074..6f40a581a5a4 100644 --- a/packages/react/src/components/UIShell/HeaderMenu.js +++ b/packages/react/src/components/UIShell/HeaderMenu.js @@ -105,9 +105,14 @@ 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 }); + if ( + event.relatedTarget && + event.relatedTarget.getAttribute('href') !== '#' + ) { + return; } + + this.setState({ expanded: false, selectedIndex: null }); }; /** From 86a84a25d5f7d53730333e4b8fcac59341a40a3d Mon Sep 17 00:00:00 2001 From: Greg McLean Date: Mon, 13 Jan 2020 16:37:42 -0400 Subject: [PATCH 2/2] fix(uishell): check for sub menu item on blur --- packages/react/src/components/UIShell/HeaderMenu.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/react/src/components/UIShell/HeaderMenu.js b/packages/react/src/components/UIShell/HeaderMenu.js index 6f40a581a5a4..d9e83c75165a 100644 --- a/packages/react/src/components/UIShell/HeaderMenu.js +++ b/packages/react/src/components/UIShell/HeaderMenu.js @@ -105,9 +105,13 @@ class HeaderMenu extends React.Component { handleOnBlur = event => { // Rough guess for a blur event that is triggered outside of our menu or // menubar context + const itemTriggeredBlur = this.items.find( + element => element === event.relatedTarget + ); + if ( event.relatedTarget && - event.relatedTarget.getAttribute('href') !== '#' + (event.relatedTarget.getAttribute('href') !== '#' || itemTriggeredBlur) ) { return; }