Skip to content

Commit

Permalink
Updated UX for ValueSetSelect component (#9685)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhimanyurajeesh authored Jan 3, 2025
1 parent 3a4bc68 commit 0899ddf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1569,7 +1569,7 @@
"search_medication": "Search Medication",
"search_patients": "Search Patients",
"search_resource": "Search Resource",
"searching": "Searching",
"searching": "Searching...",
"see_attachments": "See Attachments",
"select": "Select",
"select_all": "Select All",
Expand Down
11 changes: 8 additions & 3 deletions src/components/Questionnaire/ValueSetSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useQuery } from "@tanstack/react-query";
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";

import { cn } from "@/lib/utils";

Expand Down Expand Up @@ -29,7 +30,6 @@ interface Props {
value?: Code | null;
onSelect: (value: Code) => void;
placeholder?: string;
noResultsMessage?: string;
disabled?: boolean;
count?: number;
}
Expand All @@ -39,10 +39,10 @@ export default function ValueSetSelect({
value,
onSelect,
placeholder = "Search...",
noResultsMessage = "No results found",
disabled,
count = 10,
}: Props) {
const { t } = useTranslation();
const [open, setOpen] = useState(false);
const [search, setSearch] = useDebouncedState("", 500);

Expand Down Expand Up @@ -83,8 +83,13 @@ export default function ValueSetSelect({
/>
<CommandList>
<CommandEmpty>
{searchQuery.isFetching ? "Searching..." : noResultsMessage}
{search.length < 3
? t("min_char_length_error", { min_length: 3 })
: searchQuery.isFetching
? t("searching")
: t("no_results_found")}
</CommandEmpty>

<CommandGroup>
{searchQuery.data?.results.map((option) => (
<CommandItem
Expand Down

0 comments on commit 0899ddf

Please sign in to comment.