disabled state for select multiple

This commit is contained in:
Nate Kelley 2025-03-03 12:53:37 -07:00
parent bc3014f3d4
commit 2b3aff1903
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
2 changed files with 6 additions and 2 deletions

View File

@ -116,7 +116,7 @@ const DatasetListContainer: React.FC<{
selectedDatasets: string[];
setSelectedDatasets: React.Dispatch<React.SetStateAction<string[]>>;
}> = React.memo(({ selectedDatasets, setSelectedDatasets }) => {
const { data: datasetsList, isLoading } = useGetDatasets();
const { data: datasetsList, isLoading, isFetched } = useGetDatasets();
const onChange = useMemoizedFn((v: string[]) => {
setSelectedDatasets(v);
@ -134,6 +134,7 @@ const DatasetListContainer: React.FC<{
return (
<SelectMultiple
items={selectOptions}
disabled={!isFetched}
onSelect={onChange}
placeholder="Select a dataset"
value={selectedDatasets}

View File

@ -16,6 +16,7 @@ interface SelectMultipleProps extends VariantProps<typeof selectVariants> {
className?: string;
placeholder?: string;
value: string[];
disabled?: boolean;
}
export const SelectMultiple: React.FC<SelectMultipleProps> = React.memo(
@ -26,7 +27,8 @@ export const SelectMultiple: React.FC<SelectMultipleProps> = React.memo(
placeholder = 'Select items...',
size = 'default',
variant = 'default',
value
value,
disabled
}) => {
const selectedRecord = useMemo(() => {
return itemsProp.reduce<Record<string, boolean>>((acc, item) => {
@ -80,6 +82,7 @@ export const SelectMultiple: React.FC<SelectMultipleProps> = React.memo(
selectVariants({ variant, size }),
'relative overflow-hidden pr-0',
selectedItems.length > 0 && 'pl-1!',
disabled && 'cursor-not-allowed opacity-80',
className
)}>
<div className="scrollbar-hide flex h-full flex-nowrap items-center gap-1 overflow-x-auto">