1 import type { RefObject } from 'react';
2 import { useEffect, useRef } from 'react';
4 import type { SelectedDrawerOption } from '@proton/components/components/drawer/views/DrawerView';
5 import { CONTACT_TAB } from '@proton/components/components/drawer/views/interface';
7 const useDrawerParent = (searchInputRef: RefObject<HTMLInputElement>, tab: SelectedDrawerOption) => {
8 const animationEnded = useRef(false);
10 const onFocusSearchInput = () => {
11 searchInputRef?.current?.focus();
12 animationEnded.current = true;
15 // When we switch tab (contact, contact group, setting), we also want to focus the search input
17 if (animationEnded.current && tab.value === CONTACT_TAB.CONTACT) {
22 return { onFocusSearchInput };
25 export default useDrawerParent;