studiobakers / react-ui-toolkit

Bakers Studio's React-based UI Toolkit
MIT License
15 stars 2 forks source link

Checkbox: onSelect should be able to return context #42

Closed burakguneli closed 3 years ago

burakguneli commented 3 years ago
export interface CheckboxInputItem {
    testid?: string;
    id: string;
    content: React.ReactNode;
    inputProps: {
        htmlFor: string;
        value: string;
        name: string;
    };
}
export interface CheckboxInputProps {
    item: CheckboxInputItem;
    onSelect: (name: string, item: CheckboxInputItem) => void;
    isSelected: boolean;
    isDisabled?: boolean;
    customClassName?: string;
}

we should add one parameter to onSelect so that instead of using only one string field we can use the whole context of the option

edizcelik commented 3 years ago

Adding a context property to CheckboxInputItem would be better, I think. We already have access to item on onSelect.

edizcelik commented 3 years ago

We probably should have swapped the order of parameters from the beginning as well:

onSelect: (item: CheckboxInputItem, name?: string) => void;

as the second argument, we might actually pass the whole event object instead of just name