react-useportal
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -66,3 +66,2 @@ "use strict"; | ||
throw Error(errorMessage1); | ||
const { left, top } = targetEl.current.getBoundingClientRect(); | ||
if (onOpen) | ||
@@ -80,3 +79,3 @@ handleEvent(onOpen, event); | ||
}, [isServer, handleEvent, onClose, setOpen]); | ||
const togglePortal = react_1.useCallback((e) => isOpen ? closePortal(e) : openPortal(e), [isOpen, closePortal, openPortal]); | ||
const togglePortal = react_1.useCallback((e) => open.current ? closePortal(e) : openPortal(e), [closePortal, openPortal]); | ||
const handleKeydown = react_1.useCallback(e => { | ||
@@ -92,3 +91,3 @@ var ESC = 27; | ||
return; | ||
if (portal.current.contains(e.target) || e.button !== 0 || !open.current) | ||
if (portal.current.contains(e.target) || e.button !== 0 || !open.current || targetEl.current.contains(e.target)) | ||
return; | ||
@@ -95,0 +94,0 @@ if (closeOnOutsideClick) |
{ | ||
"name": "react-useportal", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"homepage": "https://codesandbox.io/s/w6jp7z4pkk", | ||
@@ -5,0 +5,0 @@ "main": "dist/usePortal.js", |
@@ -86,6 +86,8 @@ <p style="text-align: center;" align="center"> | ||
const App = () => { | ||
const { Portal } = usePortal() | ||
const { Portal } = usePortal({ | ||
bindTo: document && document.getElementById('san-francisco') | ||
}) | ||
return ( | ||
<Portal bindTo={document && document.getElementById('san-francisco')}> | ||
<Portal> | ||
This text is portaled into San Francisco! | ||
@@ -92,0 +94,0 @@ </Portal> |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
245
24537
148