Skip to content

Commit b96e7fd

Browse files
committed
fix: improve organization autocomplete
1 parent f959a08 commit b96e7fd

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

site/src/components/OrganizationAutocomplete/OrganizationAutocomplete.tsx

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import type { Organization } from "api/typesGenerated";
1414
import { Avatar } from "components/Avatar/Avatar";
1515
import { AvatarData } from "components/AvatarData/AvatarData";
1616
import { useDebouncedFunction } from "hooks/debounce";
17-
// import { prepareQuery } from "utils/filters";
1817

1918
export type OrganizationAutocompleteProps = {
2019
value: Organization | null;
@@ -38,14 +37,6 @@ export const OrganizationAutocomplete: FC<OrganizationAutocompleteProps> = ({
3837
value: value?.name ?? "",
3938
open: false,
4039
});
41-
// const usersQuery = useQuery({
42-
// ...users({
43-
// q: prepareQuery(encodeURI(autoComplete.value)),
44-
// limit: 25,
45-
// }),
46-
// enabled: autoComplete.open,
47-
// keepPreviousData: true,
48-
// });
4940
const organizationsQuery = useQuery(organizations());
5041

5142
const { debounced: debouncedInputOnChange } = useDebouncedFunction(
@@ -60,10 +51,8 @@ export const OrganizationAutocomplete: FC<OrganizationAutocompleteProps> = ({
6051

6152
return (
6253
<Autocomplete
63-
// Since the values are filtered by the API we don't need to filter them
64-
// in the FE because it can causes some mismatches.
6554
filterOptions={(organization) => organization}
66-
noOptionsText="No users found"
55+
noOptionsText="No organizations found"
6756
className={className}
6857
options={organizationsQuery.data ?? []}
6958
loading={organizationsQuery.isLoading}
@@ -88,14 +77,14 @@ export const OrganizationAutocomplete: FC<OrganizationAutocompleteProps> = ({
8877
isOptionEqualToValue={(option: Organization, value: Organization) =>
8978
option.name === value.name
9079
}
91-
getOptionLabel={(option) => option.name}
80+
getOptionLabel={(option) => option.display_name}
9281
renderOption={(props, option) => {
9382
const { key, ...optionProps } = props;
9483
return (
9584
<li key={key} {...optionProps}>
9685
<AvatarData
97-
title={option.name}
98-
subtitle={option.display_name}
86+
title={option.display_name}
87+
subtitle={option.name}
9988
src={option.icon}
10089
/>
10190
</li>
@@ -107,12 +96,14 @@ export const OrganizationAutocomplete: FC<OrganizationAutocompleteProps> = ({
10796
fullWidth
10897
size={size}
10998
label={label}
99+
autoFocus
110100
placeholder="Organization name"
111101
css={{
112102
"&:not(:has(label))": {
113103
margin: 0,
114104
},
115105
}}
106+
required
116107
InputProps={{
117108
...params.InputProps,
118109
onChange: debouncedInputOnChange,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy