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

🩹 Fix bad type for onAddItem #821

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/molecules/Select/ComboBox/ComboBox.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,11 @@ export const ComboBoxInDialog: StoryFn = (args) => {
export const ComboBoxWithAdd: StoryFn = (args) => {
const [values, setValues] = useState<SelectOption<Item>[]>([]);
const handleOnSelect = (newValues: SelectOptionRequired[]) => {
actions('onSelect').onSelect(newValues);
setValues(newValues);
};

const handleOnAdd = (value: string): void => {
const handleOnAdd = (value: string) => {
actions('onItemAdd').onItemAdd(value);
const newItem = {
label: value,
Expand All @@ -241,7 +242,6 @@ export const ComboBoxWithAdd: StoryFn = (args) => {
{...args}
values={values as SelectOptionRequired[]}
items={FAKE_ITEMS}
groups={undefined}
onSelect={handleOnSelect}
onAddItem={handleOnAdd}
/>
Expand Down
4 changes: 3 additions & 1 deletion src/molecules/Select/ListSelectMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
NoTagFoundText,
} from 'src/molecules/Select/Select.styles';
import {
ListSelectMenuProps,
ListSelectProps,
MultiSelectCommon,
SelectMenuProps,
Expand All @@ -23,9 +24,10 @@ import { SelectMenuItem } from 'src/molecules/Select/SelectMenuItem';

export const ListSelectMenu = <T extends SelectOptionRequired>(
props: ListSelectProps<T> &
ListSelectMenuProps &
SelectMenuProps<T> &
(
| Omit<MultiSelectCommon<T>, 'onAddItem' | 'syncParentChildSelection'>
| Omit<MultiSelectCommon<T>, 'syncParentChildSelection'>
| SingleSelectCommon<T>
)
) => {
Expand Down
5 changes: 4 additions & 1 deletion src/molecules/Select/Select.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@ export interface GroupedSelectProps<T extends SelectOptionRequired> {

export interface ListSelectProps<T extends SelectOptionRequired> {
items: SelectOption<T>[];
onAddItem?: () => void;
groups?: undefined;
}

export interface ListSelectMenuProps {
onAddItem?: () => void;
}

export interface SelectMenuProps<T extends SelectOptionRequired> {
search: string;
itemRefs: MutableRefObject<(HTMLButtonElement | null)[]>;
Expand Down