Skip to content
Merged
Show file tree
Hide file tree
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
22 changes: 14 additions & 8 deletions packages/material-ui/src/ClickAwayListener/ClickAwayListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,20 @@ const ClickAwayListener = React.forwardRef(function ClickAwayListener(props, ref
return;
}

// Multi window support
const doc = ownerDocument(nodeRef.current);

if (
doc.documentElement &&
doc.documentElement.contains(event.target) &&
!nodeRef.current.contains(event.target)
) {
let insideDOM;

// If not enough, can use https://github.com/DieterHolvoet/event-propagation-path/blob/master/propagationPath.js
if (event.composedPath) {
insideDOM = event.composedPath().indexOf(nodeRef.current) > -1;
} else {
const doc = ownerDocument(nodeRef.current);
// TODO v6 remove dead logic https://caniuse.com/#search=composedPath.
insideDOM =
!(doc.documentElement && doc.documentElement.contains(event.target)) ||
nodeRef.current.contains(event.target);
}

if (!insideDOM) {
onClickAway(event);
}
});
Expand Down
3 changes: 2 additions & 1 deletion packages/material-ui/src/Tooltip/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ const Tooltip = React.forwardRef(function Tooltip(props, ref) {
...other,
...children.props,
className: clsx(other.className, children.props.className),
ref: handleRef,
};

const interactiveWrapperListeners = {};
Expand Down Expand Up @@ -502,7 +503,7 @@ const Tooltip = React.forwardRef(function Tooltip(props, ref) {

return (
<React.Fragment>
{React.cloneElement(children, { ref: handleRef, ...childrenProps })}
{React.cloneElement(children, childrenProps)}
<Popper
className={clsx(classes.popper, {
[classes.popperInteractive]: interactive,
Expand Down