From 8cf572858ce2f0ec2a7765b31efbcf08d189e67b Mon Sep 17 00:00:00 2001 From: "Michael S. Molina" <70410625+michael-s-molina@users.noreply.github.com> Date: Thu, 1 Dec 2022 10:53:52 -0500 Subject: [PATCH] feat: Automatically closes the DropdownContainer when scrolling outside of the component (#22287) --- .../src/components/DropdownContainer/index.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/superset-frontend/src/components/DropdownContainer/index.tsx b/superset-frontend/src/components/DropdownContainer/index.tsx index 2d0e3af1d..92a2ff82e 100644 --- a/superset-frontend/src/components/DropdownContainer/index.tsx +++ b/superset-frontend/src/components/DropdownContainer/index.tsx @@ -272,6 +272,16 @@ const DropdownContainer = forwardRef( [ref], ); + // Closes the popover when scrolling on the document + useEffect(() => { + document.onscroll = popoverVisible + ? () => setPopoverVisible(false) + : null; + return () => { + document.onscroll = null; + }; + }, [popoverVisible]); + return (