Fix tcs type errors
CI Pipeline / test (20) (pull_request) Successful in 3m13s
CI Pipeline / test (18) (pull_request) Successful in 3m57s
CI Pipeline / e2e (firefox) (pull_request) Successful in 5m6s
CI Pipeline / e2e (webkit) (pull_request) Successful in 5m16s
CI Pipeline / e2e (chromium) (pull_request) Successful in 14m47s
CI Pipeline / performance (pull_request) Successful in 4m32s
CI Pipeline / storybook (pull_request) Successful in 1m35s
CI Pipeline / visual-regression (pull_request) Failing after 9m55s
CI Pipeline / lint (pull_request) Failing after 49s
CI Pipeline / build (pull_request) Successful in 1m48s

This commit is contained in:
adilallo
2025-12-11 09:05:18 -07:00
parent 92a3337aeb
commit c7e3048c09
92 changed files with 53556 additions and 915 deletions
+20 -5
View File
@@ -8,6 +8,7 @@ import React, {
useEffect,
useCallback,
memo,
useImperativeHandle,
} from "react";
import SelectDropdown from "./SelectDropdown";
import SelectOption from "./SelectOption";
@@ -61,6 +62,11 @@ const Select = forwardRef<HTMLButtonElement, SelectProps>(
const selectRef = useRef<HTMLButtonElement>(null);
const menuRef = useRef<HTMLDivElement>(null);
useImperativeHandle(
ref,
() => selectRef.current as HTMLButtonElement | null,
);
// Handle click outside to close menu
useEffect(() => {
const handleClickOutside = (event: MouseEvent) => {
@@ -260,11 +266,20 @@ const Select = forwardRef<HTMLButtonElement, SelectProps>(
// Handle children (option elements)
const selectedOption = React.Children.toArray(children).find(
(child) =>
React.isValidElement(child) && child.props.value === selectedValue,
) as
| React.ReactElement<{ value: string; children: React.ReactNode }>
| undefined;
(
child,
): child is React.ReactElement<{
value: string;
children: React.ReactNode;
}> => {
if (!React.isValidElement(child)) return false;
const props = child.props as {
value?: string;
children?: React.ReactNode;
};
return props.value === selectedValue;
},
);
return selectedOption
? String(selectedOption.props.children)
: placeholder;