diff --git a/apps/web/lib/components/auto-complete-dropdown.tsx b/apps/web/lib/components/auto-complete-dropdown.tsx index a91b05ac5..78119d1f3 100644 --- a/apps/web/lib/components/auto-complete-dropdown.tsx +++ b/apps/web/lib/components/auto-complete-dropdown.tsx @@ -3,8 +3,8 @@ import React, { Dispatch, KeyboardEvent, PropsWithChildren, SetStateAction, useCallback, useState } from 'react'; import { Transition, Combobox } from '@headlessui/react'; import { clsxm } from '@app/utils'; -import { Card } from './card'; import { Text } from './typography'; +import { IInviteEmail } from '@/app/interfaces'; type DropdownItem = { key: React.Key; @@ -29,6 +29,8 @@ type Props = { disabled?: boolean; error?: string; useHandleKeyUp?: boolean; + setSelectedEmail?: Dispatch>; + selectedEmail?: IInviteEmail | undefined; } & PropsWithChildren; export function AutoCompleteDropdown({ @@ -43,7 +45,9 @@ export function AutoCompleteDropdown({ handleAddNew, disabled = false, error = '', - useHandleKeyUp = false + useHandleKeyUp = false, + setSelectedEmail, + selectedEmail }: Props) { const [query, setQuery] = useState(''); let filteredItem = items; @@ -68,11 +72,14 @@ export function AutoCompleteDropdown({ ); return ( -
- +
+ setQuery(event.target.value)} + onChange={(event) => { + setQuery(event.target.value); + setSelectedEmail?.({ name: selectedEmail?.name ?? '', title: event.target.value }); + }} className={clsxm( 'input-border ', 'w-full flex justify-between rounded-[0.625rem] px-3 py-2 text-sm items-center bg-transparent', @@ -83,6 +90,7 @@ export function AutoCompleteDropdown({ displayValue={(item: T) => item?.data?.title} autoFocus onKeyUp={handleKeyUp} + value={query} /> ({ > - +
{/* This should only show when New item needs to be created */} {query && handleAddNew && ( ({ onClick={() => { handleAddNew(query); }} - className="font-medium cursor-pointer mb-3" + className="font-medium cursor-pointer mb-3 flex items-center h-full" >
{`${query}`}
@@ -132,7 +136,7 @@ export function AutoCompleteDropdown({ {/* Additional content */} {children} - +
diff --git a/apps/web/lib/features/team/invite/invite-email-dropdown.tsx b/apps/web/lib/features/team/invite/invite-email-dropdown.tsx index 5fda03568..c2c39eba9 100644 --- a/apps/web/lib/features/team/invite/invite-email-dropdown.tsx +++ b/apps/web/lib/features/team/invite/invite-email-dropdown.tsx @@ -19,8 +19,8 @@ export const InviteEmailDropdown = ({ selectedEmail: IInviteEmail | undefined; error: string; handleAddNew: (email: string) => void; - }) => { - const t = useTranslations() +}) => { + const t = useTranslations(); const items = useMemo(() => mapTeamMemberItems(emails), [emails]); const $items = useSyncRef(items); @@ -54,6 +54,8 @@ export const InviteEmailDropdown = ({ error={error} handleAddNew={handleAddNew} useHandleKeyUp={true} + setSelectedEmail={setSelectedEmail} + selectedEmail={selectedEmail} /> );