diff --git a/client/components/stats-interval-dropdown/index.jsx b/client/components/stats-interval-dropdown/index.jsx index c80df41e68b1a..0dd65a6c027d2 100644 --- a/client/components/stats-interval-dropdown/index.jsx +++ b/client/components/stats-interval-dropdown/index.jsx @@ -5,9 +5,20 @@ import { check, Icon, chevronDown, lock } from '@wordpress/icons'; import clsx from 'clsx'; import { capitalize } from 'lodash'; import qs from 'qs'; +import { useRef } from 'react'; import './style.scss'; +import useOutsideClickCallback from 'calypso/lib/use-outside-click-callback'; + +const StatsIntervalDropdownListing = ( { + selected, + onSelection, + intervals, + onGatedHandler, + onClickOutside, +} ) => { + const ref = useRef( null ); + useOutsideClickCallback( ref, onClickOutside ); -const StatsIntervalDropdownListing = ( { selected, onSelection, intervals, onGatedHandler } ) => { const isOdysseyStats = config.isEnabled( 'is_running_in_jetpack_site' ); const isSelectedItem = ( interval ) => { @@ -33,7 +44,7 @@ const StatsIntervalDropdownListing = ( { selected, onSelection, intervals, onGat }; return ( -