feat: Automatically closes the DropdownContainer when scrolling outside of the component (#22287)
This commit is contained in:
parent
309c064cc8
commit
8cf572858c
|
|
@ -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 (
|
||||
<div
|
||||
ref={ref}
|
||||
|
|
|
|||
Loading…
Reference in New Issue