From 9745f06c4c54ddc357c1d53c84f6a50db7de3f76 Mon Sep 17 00:00:00 2001 From: Rodrigo Antinarelli Date: Tue, 23 Jun 2020 23:40:35 -0300 Subject: [PATCH] fix eventListener --- platform/ui/src/components/Dropdown/Dropdown.jsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/platform/ui/src/components/Dropdown/Dropdown.jsx b/platform/ui/src/components/Dropdown/Dropdown.jsx index 752e2b6f9..8d298dc86 100644 --- a/platform/ui/src/components/Dropdown/Dropdown.jsx +++ b/platform/ui/src/components/Dropdown/Dropdown.jsx @@ -10,7 +10,7 @@ const Dropdown = ({ titleElement, title, list }) => { const renderTitleElement = () => { if (titleElement) { - return titleElement; + return <>{titleElement}; } return ( @@ -74,10 +74,10 @@ const Dropdown = ({ titleElement, title, list }) => { useEffect(() => { document.addEventListener('click', handleClick); - return () => { + if (!open) { document.removeEventListener('click', handleClick); - }; - }, []); + } + }, [open]); return (
@@ -92,12 +92,12 @@ const Dropdown = ({ titleElement, title, list }) => { Dropdown.propTypes = { titleElement: PropTypes.node, - title: PropTypes.string.isRequired, + title: PropTypes.string, /** Items to render in the select's drop down */ list: PropTypes.arrayOf( PropTypes.shape({ title: PropTypes.string.isRequired, - icon: PropTypes.object, + icon: PropTypes.string, onClick: PropTypes.func, link: PropTypes.string, })