Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jan 6, 2022
Merged
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
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