Skip to content

Commit

Permalink
[popover2] fix(Popover2): close properly when target focus lost (#5080)
Browse files Browse the repository at this point in the history
specifically applies to hover interaction popovers & tooltips
  • Loading branch information
dlech authored Jan 6, 2022
1 parent 4b87c17 commit 8e4fd63
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/popover2/src/popover2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -536,10 +536,6 @@ export class Popover2<T> extends AbstractPureComponent2<Popover2Props<T>, IPopov

private handleTargetBlur = (e: React.FocusEvent<HTMLElement>) => {
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.
Expand All @@ -549,6 +545,8 @@ export class Popover2<T> extends AbstractPureComponent2<Popover2Props<T>, IPopov
) {
this.handleMouseLeave((e as unknown) as React.MouseEvent<HTMLElement>);
}
} else {
this.handleMouseLeave((e as unknown) as React.MouseEvent<HTMLElement>);
}
}
this.lostFocusOnSamePage = e.relatedTarget != null;
Expand Down

1 comment on commit 8e4fd63

@blueprint-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[popover2] fix(Popover2): close properly when target focus lost (#5080)

Previews: documentation | landing | table | modern colors demo

Please sign in to comment.