Skip to content

Commit

Permalink
review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
hoorayimhelping committed Feb 13, 2025
1 parent 4547713 commit 5f21955
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/components/Select/MultiSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { KeyboardEvent, useCallback, useState } from "react";
import { KeyboardEvent, MouseEvent, useCallback, useState } from "react";

import { useUpdateEffect } from "@/hooks";

Expand All @@ -14,7 +14,7 @@ export interface MultiSelectProps
onSelect?: (
value: Array<string>,
type?: SelectionType,
evt?: KeyboardEvent<HTMLElement>
evt?: KeyboardEvent<HTMLElement> | MouseEvent<HTMLElement>
) => void;
value?: Array<string>;
defaultOpen?: boolean;
Expand Down
10 changes: 7 additions & 3 deletions src/components/Select/SingleSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { KeyboardEvent, useCallback, useState } from "react";
import { KeyboardEvent, MouseEvent, useCallback, useState } from "react";

import { useUpdateEffect } from "@/hooks";

Expand All @@ -14,7 +14,7 @@ export interface SelectProps
onSelect?: (
value: string,
type?: SelectionType,
evt?: KeyboardEvent<HTMLElement>
evt?: KeyboardEvent<HTMLElement> | MouseEvent<HTMLElement>
) => void;
value?: string;
placeholder?: string;
Expand Down Expand Up @@ -52,7 +52,11 @@ export const Select = ({
);

const onSelect = useCallback(
(value: string, type?: SelectionType, evt?: KeyboardEvent<HTMLElement>) => {
(
value: string,
type?: SelectionType,
evt?: KeyboardEvent<HTMLElement> | MouseEvent<HTMLElement>
) => {
setSelectedValues(values => {
if (values[0] !== value) {
return [value];
Expand Down
4 changes: 2 additions & 2 deletions src/components/Select/common/InternalSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ export const InternalSelect = ({
if (e.key === "Enter") {
e.preventDefault();
if (highlighted) {
onSelect(highlighted, "default", e);
onSelect(highlighted, undefined, e);
} else if (visibleList.current.length === 0 && allowCreateOption) {
onSelect(search, "custom", e);
}
Expand Down Expand Up @@ -306,7 +306,7 @@ export const InternalSelect = ({
e.preventDefault();
e.stopPropagation();
if (allowCreateOption) {
onSelect(search, "custom");
onSelect(search, "custom", e);
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/components/Select/common/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HTMLAttributes, KeyboardEvent, ReactNode } from "react";
import { HTMLAttributes, KeyboardEvent, MouseEvent, ReactNode } from "react";
import { HorizontalDirection, IconName } from "@/components";
import { PopoverProps } from "@radix-ui/react-popover";

Expand Down Expand Up @@ -77,7 +77,7 @@ interface InternalSelectProps
onSelect: (
value: string,
type?: SelectionType,
evt?: KeyboardEvent<HTMLElement>
evt?: KeyboardEvent<HTMLElement> | MouseEvent<HTMLElement>
) => void;
multiple?: boolean;
checkbox?: boolean;
Expand Down

0 comments on commit 5f21955

Please sign in to comment.