From 8e4fd638861bbcf27ebe94dec7602c70838355f7 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Thu, 6 Jan 2022 14:20:15 -0600 Subject: [PATCH] [popover2] fix(Popover2): close properly when target focus lost (#5080) specifically applies to hover interaction popovers & tooltips --- packages/popover2/src/popover2.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/popover2/src/popover2.tsx b/packages/popover2/src/popover2.tsx index cf1e5f27ed..7cfa660a97 100644 --- a/packages/popover2/src/popover2.tsx +++ b/packages/popover2/src/popover2.tsx @@ -536,10 +536,6 @@ export class Popover2 extends AbstractPureComponent2, IPopov private handleTargetBlur = (e: React.FocusEvent) => { if (this.props.openOnTargetFocus && this.isHoverInteractionKind()) { - // e.relatedTarget ought to tell us the next element to receive focus, but if the user just - // clicked on an element which is not focusable (either by default or with a tabIndex attribute), - // it won't be set. So, we filter those out here and assume that a click handler somewhere else will - // close the popover if necessary. if (e.relatedTarget != null) { // if the next element to receive focus is within the popover, we'll want to leave the // popover open. @@ -549,6 +545,8 @@ export class Popover2 extends AbstractPureComponent2, IPopov ) { this.handleMouseLeave((e as unknown) as React.MouseEvent); } + } else { + this.handleMouseLeave((e as unknown) as React.MouseEvent); } } this.lostFocusOnSamePage = e.relatedTarget != null;