Skip to content

Commit

Permalink
feat: 🎸 [Select] Added onClose property
Browse files Browse the repository at this point in the history
✅ Closes: 215
  • Loading branch information
luciob committed Oct 6, 2021
1 parent ce77852 commit 35baab3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/components/Select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const Select = <T extends any>({
loading = false,
multiple = false,
onChange: externalOnChange,
onClose: externalOnClose,
onInputChange: externalOnInputChange,
onScrollEnd,
options: externalOptions,
Expand Down Expand Up @@ -95,6 +96,18 @@ const Select = <T extends any>({
[externalOnChange]
);

const onClose = useCallback(
(event) => {
if (!externalOnClose) {
return;
}

suppressEvent(event);
externalOnClose();
},
[externalOnClose]
);

const onInputChange = useCallback(
(event, value: any) => {
if (!externalOnInputChange) {
Expand Down Expand Up @@ -184,6 +197,7 @@ const Select = <T extends any>({
loading={loading}
multiple={multiple}
onChange={onChange}
onClose={onClose}
onInputChange={onInputChange}
options={options}
PopperComponent={(props: MUIPopperProps) => {
Expand Down
1 change: 1 addition & 0 deletions src/types/Select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface IBaseSelect<T> extends ILocalizable, ILoadable, IInput {
getOptionLabel?: (option: T) => string;
getOptionSelected?: (option: T, value: T) => boolean;
groupBy?: (option: T) => string;
onClose?: () => void;
onInputChange?: (input: string) => void;
onScrollEnd?: () => void;
options: T[];
Expand Down

0 comments on commit 35baab3

Please sign in to comment.