Skip to content

Commit

Permalink
fix storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
jsartisan committed Feb 3, 2025
1 parent 9eba1e3 commit e839073
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Icon } from "../Icon";
import { Checkbox } from "../Checkbox";
import type { SelectProps } from "./Select.types";
import type { StoryObj } from "@storybook/react";
import type { DefaultOptionType } from "rc-select/lib/Select";

export default {
title: "ADS/Components/Select",
Expand Down Expand Up @@ -995,19 +996,19 @@ const groupOptions = [
];

export function SelectWithCheckboxAndGroup() {
const [selectedOptions, setSelectedOptions] = useState([]);
const [selectedOptions, setSelectedOptions] = useState<DefaultOptionType[]>(
[],
);

return (
<Select
isMultiSelect
onDeselect={(value, unselectedOption) =>
setSelectedOptions(
// @ts-expect-error type error
selectedOptions.filter((opt) => opt.value !== unselectedOption.value),
)
}
onSelect={(value, newSelectedOption) =>
// @ts-expect-error type error
setSelectedOptions([...selectedOptions, newSelectedOption])
}
placeholder="Select options"
Expand All @@ -1024,9 +1025,12 @@ export function SelectWithCheckboxAndGroup() {
value={option.value}
>
<Checkbox
isSelected={selectedOptions.find(
// @ts-expect-error type error
(selectedOption) => selectedOption.value == option.value,
// making it read only as it is interfering with selection of options of rc-select
isReadOnly
isSelected={Boolean(
selectedOptions.find(
(selectedOption) => selectedOption.value == option.value,
),
)}
>
{option.label}
Expand Down
5 changes: 5 additions & 0 deletions app/client/packages/design-system/ads/src/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ function Select(props: SelectProps) {

searchRef.current?.focus();
}, 200);

return;
}

setSearchValue("");
};

return (
Expand All @@ -89,6 +93,7 @@ function Select(props: SelectProps) {
placeholder="Type to search..."
ref={searchRef}
size="md"
value={searchValue}
/>
)}
{menu}
Expand Down

0 comments on commit e839073

Please sign in to comment.