Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private onActivation = (node: HTMLElement) => {
this._undo = hideOthers(
[node, ...(this.props.shards || []).map(extractRef)],
document.body,
this.props.noIsolation ? undefined : focusHiddenMarker
);
const {onActivation} = this.props;
if (onActivation) {
onActivation(node);
}
document.addEventListener('keyup', this.onKeyPress);
document.addEventListener('click', this.onClick);
};
useEffect(() => {
let undoAriaHidden: Undo | null = null;
let mountNode = mountRef.current;
if (isOpen && canUseDOM && mountRef.current && container) {
mountRef.current.id = id;
container.appendChild(mountRef.current);
if (isEnabled && mountNode) {
undoAriaHidden = hideOthers(mountNode);
}
}
return () => {
if (isEnabled && undoAriaHidden != null) {
undoAriaHidden();
}
if (mountNode && mountNode.parentElement) {
mountNode.parentElement.removeChild(mountNode);
}
};
}, [isOpen, id, isEnabled, container]);
React.useEffect(() => {
if (!ref.current) return;
let undoAriaHidden: AriaHidden.Undo | null = null;
let elementNode = ref.current;
if (shouldActivate && elementNode) {
undoAriaHidden = AriaHidden.hideOthers(elementNode);
}
return () => {
if (shouldActivate && undoAriaHidden != null) {
undoAriaHidden();
}
};
}, [shouldActivate, ref]);
}
const onNodeActivation = (node: HTMLElement) => {
_undo = hideOthers(
[node, ...(shards || []).map(extractRef)],
document.body,
noIsolation ? undefined : focusHiddenMarker
);
setActiveNode(() => node);
};
useEffect(() => {
let undoAriaHidden = null;
let mountNode = mountRef.current;
if (isOpen && canUseDOM) {
mountRef.current.id = id;
container.appendChild(mountRef.current);
if (enableInert) {
undoAriaHidden = hideOthers(mountNode);
}
}
return () => {
if (enableInert && undoAriaHidden != null) {
undoAriaHidden();
}
if (mountNode.parentElement) {
mountNode.parentElement.removeChild(mountNode);
}
};
}, [isOpen, id, enableInert, container]);