Compare commits

...

2 Commits

Author SHA1 Message Date
gakshita a405c14939 fix: added custom prop for closeOnSelect 2025-10-08 18:28:40 +05:30
gakshita 61ee99cf5f fix: custom select auto close on select 2025-10-08 17:13:14 +05:30
2 changed files with 7 additions and 2 deletions
+6 -2
View File
@@ -29,6 +29,7 @@ const CustomSelect = (props: ICustomSelectProps) => {
optionsClassName = "",
value,
tabIndex,
closeOnSelect = true,
} = props;
// states
const [referenceElement, setReferenceElement] = useState<HTMLButtonElement | null>(null);
@@ -60,7 +61,10 @@ const CustomSelect = (props: ICustomSelectProps) => {
ref={dropdownRef}
tabIndex={tabIndex}
value={value}
onChange={onChange}
onChange={(val) => {
onChange?.(val);
if (closeOnSelect) closeDropdown();
}}
className={cn("relative flex-shrink-0 text-left", className)}
onKeyDown={handleKeyDown}
disabled={disabled}
@@ -71,7 +75,7 @@ const CustomSelect = (props: ICustomSelectProps) => {
<button
ref={setReferenceElement}
type="button"
className={`flex items-center justify-between gap-1 text-xs ${
className={`flex items-center justify-between gap-1 text-xs rounded ${
disabled ? "cursor-not-allowed text-custom-text-200" : "cursor-pointer hover:bg-custom-background-80"
} ${customButtonClassName}`}
onClick={toggleDropdown}
+1
View File
@@ -59,6 +59,7 @@ export interface ICustomSelectProps extends IDropdownProps {
children: React.ReactNode;
value: any;
onChange: any;
closeOnSelect?: boolean;
}
interface CustomSearchSelectProps {