Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
focus() {
let autoFocus = this.props.autoFocus;
let modalContent = this.getDialogElement();
let current = activeElement(ownerDocument(this));
let focusInModal = current && contains(modalContent, current);
if (modalContent && autoFocus && !focusInModal) {
this.lastFocus = current;
if (!modalContent.hasAttribute('tabIndex')) {
modalContent.setAttribute('tabIndex', -1);
new Error(false, '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();
}
},
enforceFocus() {
let {enforceFocus} = this.props;
if (!enforceFocus || !this.isMounted() || !this.isTopModal()) {
return;
}
let active = activeElement(ownerDocument(this));
let modal = this.getDialogElement();
if (modal && modal !== active && !contains(modal, active)) {
modal.focus();
}
},
export default function handleMouseOverOut(handler: Function, event: SyntheticEvent<*>) {
let target = event.currentTarget;
let related = event.relatedTarget || _.get(event, ['nativeEvent', 'toElement']);
if ((!related || (related !== target)) && !contains(target, related)) {
handler(event);
}
}