Skip to content

Commit b7b3c0e

Browse files
committed
api selector hide on outside click
1 parent b419255 commit b7b3c0e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/components/ApiMenu/ApiMenu.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@ import React, { useEffect, useState } from 'react';
22
import { useTranslation, Trans } from 'react-i18next';
33
import useStore from '@store/store';
44

5+
import useHideOnOutsideClick from '@hooks/useHideOnOutsideClick';
6+
57
import PopupModal from '@components/PopupModal';
8+
69
import { availableEndpoints, defaultAPIEndpoint } from '@constants/auth';
10+
711
import DownChevronArrow from '@icon/DownChevronArrow';
812

913
const ApiMenu = ({
@@ -121,7 +125,7 @@ const ApiEndpointSelector = ({
121125
_apiEndpoint: string;
122126
_setApiEndpoint: React.Dispatch<React.SetStateAction<string>>;
123127
}) => {
124-
const [dropDown, setDropDown] = useState<boolean>(false);
128+
const [dropDown, setDropDown, dropDownRef] = useHideOnOutsideClick();
125129

126130
return (
127131
<div className='w-[40vw] relative flex-1'>
@@ -135,6 +139,7 @@ const ApiEndpointSelector = ({
135139
</button>
136140
<div
137141
id='dropdown'
142+
ref={dropDownRef}
138143
className={`${
139144
dropDown ? '' : 'hidden'
140145
} absolute top-100 bottom-100 z-10 bg-white rounded-lg shadow-xl border-b border-black/10 dark:border-gray-900/50 text-gray-800 dark:text-gray-100 group dark:bg-gray-800 opacity-90 w-32 w-full`}

0 commit comments

Comments
 (0)