Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated UX for ValueSetSelect component #9685

Merged
merged 8 commits into from
Jan 3, 2025
Merged
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
Loading