Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getContentAnchorOffset(element) {
const { getContentAnchorEl, anchorReference } = this.props;
let contentAnchorOffset = 0;
if (getContentAnchorEl && anchorReference === 'anchorEl') {
const contentAnchorEl = getContentAnchorEl(element);
if (contentAnchorEl && contains(element, contentAnchorEl)) {
const scrollTop = getScrollParent(element, contentAnchorEl);
contentAnchorOffset = contentAnchorEl.offsetTop + contentAnchorEl.clientHeight / 2 - scrollTop || 0;
}
// != the default value
process.env.NODE_ENV !== "production" ? warning(this.props.anchorOrigin.vertical === 'top', ['Material-UI: you can not change the default `anchorOrigin.vertical` value ', 'when also providing the `getContentAnchorEl` property to the popover component.', 'Only use one of the two properties.', 'Set `getContentAnchorEl` to null or left `anchorOrigin.vertical` unchanged.'].join('\n')) : void 0;
}
return contentAnchorOffset;
}
handleMouseOverOut(handler, e, relatedNative) {
const target = e.currentTarget
const related = e.relatedTarget || e.nativeEvent[relatedNative]
if ((!related || related !== target) && !contains(target, related)) {
handler(target, true)
}
}
handleMouseOverOut(handler: any, e: any, relatedNative: string) {
const target = e.currentTarget;
const related = e.relatedTarget || e.nativeEvent[relatedNative];
if ((!related || related !== target) && !contains(target, related)) {
handler(e);
}
}
handleFocusListener = () => {
if (!this.mounted || !this.props.modalManager.isTopModal(this)) {
return;
}
const currentFocus = activeElement(ownerDocument(ReactDOM.findDOMNode(this)));
const modalContent = this.modal && this.modal.lastChild;
if (modalContent && modalContent !== currentFocus && !contains(modalContent, currentFocus)) {
modalContent.focus();
}
};
handleMouseOverOut(handler, e, relatedNative) {
const target = e.currentTarget;
const related = e.relatedTarget || e.nativeEvent[relatedNative];
if ((!related || related !== target) && !contains(target, related)) {
handler(e);
}
}
componentWillUpdate(nextProps) {
if (!nextProps.open && this.props.open) {
this._focusInDropdown = contains(
ReactDOM.findDOMNode(this.menu),
activeElement(document)
);
}
}
Dropdown.prototype.componentWillUpdate = function componentWillUpdate(nextProps) {
if (!nextProps.open && this.props.open) {
this._focusInDropdown = contains(ReactDOM.findDOMNode(this.menu), activeElement(document));
}
};
getSnapshotBeforeUpdate(prevProps, prevState) {
if (!this.props.open && prevProps.open) {
const focusInDropdown = this.menu && contains(ReactDOM.findDOMNode(this.menu), activeElement(document));
return focusInDropdown;
}
return null;
}
.instance()
.getMountNode();
const container = document.getElementById('container');
const heading = document.getElementById('heading');
if (!container || !heading) {
throw new Error('missing element');
}
assert.strictEqual(
container.tagName.toLowerCase(),
'div',
'should have the element in the DOM',
);
assert.strictEqual(heading.tagName.toLowerCase(), 'h1', 'should have the element in the DOM');
assert.strictEqual(contains(portalLayer, container), true, 'should be in the portal');
assert.strictEqual(contains(portalLayer, heading), true, 'should be in the portal');
const container2 = document.getElementById('container');
if (!container2) {
throw new Error('missing container');
}
assert.strictEqual(
container2.getAttribute('role'),
'document',
'should add the document role',
);
assert.strictEqual(container2.getAttribute('tabindex'), '-1', 'should add a -1 tab-index');
});
});
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();
}
}