Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ import {
*/
let anyPopoverOpen: boolean = false;

// Track if the keyboard was used to decide if we should close the popover on blur
let wasKeyboardUsed = false;
window.addEventListener('keydown', () => {
wasKeyboardUsed = true;
});
window.addEventListener('mousedown', () => {
wasKeyboardUsed = false;
});

/**
* Utility function to check if any popover is open.
*
Expand Down Expand Up @@ -185,6 +194,8 @@ export const SideNavPopover = ({

const handleBlur: FocusEventHandler = useCallback(
(e) => {
if (!wasKeyboardUsed) return;

clearTimeout();

const nextFocused = e.relatedTarget;
Expand Down