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
3 changes: 3 additions & 0 deletions public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1807,6 +1807,9 @@
"vaccinated": "Vaccinated",
"vaccine_name": "Vaccine name",
"valid_otp_found": "Valid OTP found, Navigating to Appointments",
"valueSetSelect_noResults": "No results found",
"valueSetSelect_searching": "Searching...",
"valueSetSelect_typeMinChars": "Type at least 3 characters to search",
"vehicle_preference": "Vehicle preference",
"vendor_name": "Vendor Name",
"ventilator_interface": "Respiratory Support Type",
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("valueSetSelect_typeMinChars")
abhimanyurajeesh marked this conversation as resolved.
Show resolved Hide resolved
: searchQuery.isFetching
? t("valueSetSelect_searching")
abhimanyurajeesh marked this conversation as resolved.
Show resolved Hide resolved
: t("valueSetSelect_noResults")}
abhimanyurajeesh marked this conversation as resolved.
Show resolved Hide resolved
</CommandEmpty>

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