@@ -6,8 +6,8 @@ import GetApps from '@/graphql/queries/getApps.gql'
6
6
import { Menu , Transition } from '@headlessui/react'
7
7
import { useQuery } from '@apollo/client'
8
8
import Link from 'next/link'
9
- import { Fragment , useState } from 'react'
10
- import { FaPlus , FaChevronDown , FaSearch , FaTimesCircle , FaArrowRight } from 'react-icons/fa'
9
+ import { Fragment , useRef , useState } from 'react'
10
+ import { FaPlus , FaSearch , FaTimesCircle , FaArrowRight } from 'react-icons/fa'
11
11
import Spinner from '@/components/common/Spinner'
12
12
import clsx from 'clsx'
13
13
import { EmptyState } from '@/components/common/EmptyState'
@@ -20,6 +20,7 @@ export const AddAppToMemberButton = (props: {
20
20
} ) => {
21
21
const { member, organisationId, teamSlug } = props
22
22
const [ searchQuery , setSearchQuery ] = useState ( '' )
23
+ const searchInputRef = useRef < HTMLInputElement > ( null )
23
24
24
25
// Fetch all apps the active user has access to
25
26
const { data : allAppsData , loading : loadingApps } = useQuery < Query > ( GetApps , {
@@ -47,7 +48,7 @@ export const AddAppToMemberButton = (props: {
47
48
return (
48
49
< Menu as = "div" className = "relative inline-block text-left group" >
49
50
< Menu . Button as = { Fragment } >
50
- < Button variant = "primary" disabled = { loadingApps } >
51
+ < Button variant = "primary" title = "Add Member to App" disabled = { loadingApps } >
51
52
{ loadingApps ? (
52
53
< Spinner size = "sm" />
53
54
) : (
@@ -65,6 +66,8 @@ export const AddAppToMemberButton = (props: {
65
66
leave = "transition duration-75 ease-out"
66
67
leaveFrom = "transform scale-100 opacity-100"
67
68
leaveTo = "transform scale-95 opacity-0"
69
+ afterEnter = { ( ) => searchInputRef . current ?. focus ( ) }
70
+ afterLeave = { ( ) => setSearchQuery ( '' ) }
68
71
>
69
72
< Menu . Items className = "absolute z-10 right-0 origin-top-right mt-2 flex flex-col w-min divide-y divide-neutral-500/40 p-px rounded-md bg-neutral-200 dark:bg-neutral-800 shadow-lg ring-1 ring-inset ring-neutral-500/40 focus:outline-none" >
70
73
< div >
@@ -78,6 +81,8 @@ export const AddAppToMemberButton = (props: {
78
81
value = { searchQuery }
79
82
onChange = { ( e ) => setSearchQuery ( e . target . value ) }
80
83
onClick = { ( e ) => e . stopPropagation ( ) }
84
+ ref = { searchInputRef }
85
+ autoFocus
81
86
/>
82
87
< FaTimesCircle
83
88
className = { clsx (
0 commit comments