Skip to content
Open
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
17 changes: 13 additions & 4 deletions packages/react-accessible-tooltip/src/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,20 @@ class Tooltip extends Component<TooltipProps, TooltipState> {
activeElement instanceof Element &&
target instanceof Element &&
this.container instanceof Element &&
!this.container.contains(target) && // touch target not a tooltip descendent
this.state.isFocused // prevent redundant state change
!this.container.contains(target) // touch target not a tooltip descendent
) {
this.setState({ isFocused: false });
activeElement.blur();
// prevent redundant state change
if (this.state.isFocused) {
this.setState({ isFocused: false });
}
// prevent redundant state change
if (this.state.isHovered) {
this.setState({ isHovered: false });
}
// don't blur active element if outside
if (this.container.contains(activeElement)) {
activeElement.blur();
}
} else if (
activeElement instanceof Element &&
target instanceof Element &&
Expand Down