Skip to content

Commit

Permalink
fix(SideNav): detect child node for blur (#6043)
Browse files Browse the repository at this point in the history
This changes fixes a logic in `<SideNav>` where it detects focus on a
nav item as side nav losing focus as a whole.

Fixes #6004.
  • Loading branch information
asudoh committed May 12, 2020
1 parent f5c1606 commit 818705a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/react/src/components/UIShell/SideNav.js
Expand Up @@ -95,8 +95,16 @@ const SideNav = React.forwardRef(function SideNav(props, ref) {
let eventHandlers = {};

if (addFocusListeners) {
eventHandlers.onFocus = event => handleToggle(event, true);
eventHandlers.onBlur = event => handleToggle(event, false);
eventHandlers.onFocus = event => {
if (!event.currentTarget.contains(event.relatedTarget)) {
handleToggle(event, true);
}
};
eventHandlers.onBlur = event => {
if (!event.currentTarget.contains(event.relatedTarget)) {
handleToggle(event, false);
}
};
}

if (addMouseListeners && isRail) {
Expand Down

0 comments on commit 818705a

Please sign in to comment.