From b7b3c0ec75728812a8ff86baccb3d916b49450ad Mon Sep 17 00:00:00 2001 From: Jing Hua Date: Sat, 29 Apr 2023 23:09:29 +0800 Subject: [PATCH] api selector hide on outside click --- src/components/ApiMenu/ApiMenu.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/ApiMenu/ApiMenu.tsx b/src/components/ApiMenu/ApiMenu.tsx index 0f7d1c8..12a3b5d 100644 --- a/src/components/ApiMenu/ApiMenu.tsx +++ b/src/components/ApiMenu/ApiMenu.tsx @@ -2,8 +2,12 @@ import React, { useEffect, useState } from 'react'; import { useTranslation, Trans } from 'react-i18next'; import useStore from '@store/store'; +import useHideOnOutsideClick from '@hooks/useHideOnOutsideClick'; + import PopupModal from '@components/PopupModal'; + import { availableEndpoints, defaultAPIEndpoint } from '@constants/auth'; + import DownChevronArrow from '@icon/DownChevronArrow'; const ApiMenu = ({ @@ -121,7 +125,7 @@ const ApiEndpointSelector = ({ _apiEndpoint: string; _setApiEndpoint: React.Dispatch>; }) => { - const [dropDown, setDropDown] = useState(false); + const [dropDown, setDropDown, dropDownRef] = useHideOnOutsideClick(); return (
@@ -135,6 +139,7 @@ const ApiEndpointSelector = ({