Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} = ({ className, children, onClose, open: isOpenExternal, title }) => {
const isControlled = isBoolean(isOpenExternal);
const escapePress = useKeyPress('Escape');
const [isOpenInternal, setIsOpenInternal] = useState(true);
const isOpen = isControlled ? isOpenExternal : isOpenInternal;
const isDesktop = useMedia(t => t.media.greaterThan(t.breakpoints.sm)) || false;
const seed = useUIDSeed();
const uid = seed(displayName);
const handleCloseClick = () => {
setIsOpenInternal(false);
if (onClose) {
onClose();
}
};
useEffect(() => {
if (isOpen && escapePress) {
handleCloseClick();
}
}, [escapePress, isOpen]);