Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
handleClickAway = event => {
// Ignore events that have been `event.preventDefault()` marked.
if (event.defaultPrevented) {
return;
}
// IE11 support, which trigger the handleClickAway even after the unbind
if (!this.mounted) {
return;
}
const el = ReactDOM.findDOMNode(this);
const doc = ownerDocument(el);
if (
doc.documentElement &&
doc.documentElement.contains(event.target) &&
!isDescendant(el, event.target)
) {
this.props.onClickAway(event);
}
};
function getOwnerDocument(element) {
return ownerDocument(ReactDOM.findDOMNode(element));
}
_getStyles() {
if (!canUseDOM)
return {}
let node = findDOMNode(this.dialog)
, doc = ownerDocument(node)
, scrollHt = node.scrollHeight
, bodyIsOverflowing = isOverflowing(this.props.container || doc.body)
, modalIsOverflowing = scrollHt > doc.documentElement.clientHeight
return {
dialog: {
zIndex: getZIndex('modal'),
paddingRight: bodyIsOverflowing && !modalIsOverflowing ? scrollbarWidth() : void 0,
paddingLeft: !bodyIsOverflowing && modalIsOverflowing ? scrollbarWidth() : void 0
},
backdrop: {
zIndex: getZIndex('backdrop')
}
}
}
function ownerDocument2(componentOrElement2) {
return ownerDocument(ReactDOM.findDOMNode(componentOrElement2));
}
createTextInstance(
text: string,
rootContainerInstance: DOMContainer,
hostContext,
internalInstanceHandle,
): Text {
const inst = getOwnerDocument(rootContainerInstance).createTextNode(text);
cacheHandleByInstance(inst, internalInstanceHandle);
return inst;
},
function bodyIsOverflowing(node) {
let doc = ownerDocument(node);
let win = isWindow(doc);
return doc.body.clientWidth < win.innerWidth;
}
function createElement(type, props, rootContainerElement, isSvg): Element {
const ownerDocument = getOwnerDocument(rootContainerElement);
let domElement = isSvg
? ownerDocument.createElementNS('http://www.w3.org/2000/svg', type)
: ownerDocument.createElement(type);
return domElement;
}
focus() {
const currentFocus = activeElement(ownerDocument(ReactDOM.findDOMNode(this)));
const modalContent = this.modal && this.modal.lastChild;
const focusInModal = currentFocus && contains(modalContent, currentFocus);
if (modalContent && !focusInModal) {
if (!modalContent.hasAttribute('tabIndex')) {
modalContent.setAttribute('tabIndex', -1);
warning(
false,
'Material-UI: the modal content node does not accept focus. ' +
'For the benefit of assistive technologies, ' +
'the tabIndex of the node is being set to "-1".',
);
}
modalContent.focus();
}
updateStyle() {
if (!canUseDOM) {
return;
}
const dialogNode = this._modal.getDialogElement();
const dialogHeight = dialogNode.scrollHeight;
const document = ownerDocument(dialogNode);
const bodyIsOverflowing = isOverflowing(
ReactDOM.findDOMNode(this.props.container || document.body)
);
const modalIsOverflowing =
dialogHeight > document.documentElement.clientHeight;
this.setState({
style: {
paddingRight:
bodyIsOverflowing && !modalIsOverflowing
? getScrollbarSize()
: undefined,
paddingLeft:
!bodyIsOverflowing && modalIsOverflowing
? getScrollbarSize()
: undefined