Skip to content

Commit b8f8996

Browse files
committedMar 24, 2025·
윈도우 크로미움 환경 select 관련 문제 해결
1 parent 4fee392 commit b8f8996

File tree

1 file changed

+8
-21
lines changed

1 file changed

+8
-21
lines changed
 

‎src/components/Dropdown.tsx

+8-21
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,31 @@
11
export type OptionType = string | [string, string, boolean?] | string[];
22

3-
interface IProp
4-
extends Omit<
5-
React.HTMLAttributes<HTMLSelectElement>,
6-
'onChange' | 'defaultValue'
7-
> {
3+
interface IProp extends Omit<React.HTMLAttributes<HTMLSelectElement>, 'onChange' | 'defaultValue'> {
84
/** 드롭다운 선택지 (문자열 or [Key 문자열, Value 문자열, 배열째 반환 여부] ) */
95
options: Array<OptionType>;
106
// eslint-disable-next-line no-unused-vars
117
onChange: (data: OptionType) => void;
128
defaultValue: OptionType;
139
}
1410

15-
export const Dropdown = ({
16-
options,
17-
onChange,
18-
defaultValue,
19-
...rest
20-
}: IProp) => {
11+
export const Dropdown = ({ options, onChange, defaultValue, ...rest }: IProp) => {
2112
return (
2213
<div className="w-[100px] h-fit rounded-[4px] overflow-hidden border-BORDER-SUB bg-BG-SUB border-[1px] shrink-0 relative">
2314
<select
2415
{...rest}
2516
onChange={(e) => {
2617
const value = options.find((i) =>
27-
typeof i === 'object'
28-
? i[0] === e.target.value
29-
: i === e.target.value,
18+
typeof i === 'object' ? i[0] === e.target.value : i === e.target.value,
3019
) as OptionType;
31-
onChange(
32-
typeof value === 'object' ? (value[2] ? value : value[1]) : value,
33-
);
20+
onChange(typeof value === 'object' ? (value[2] ? value : value[1]) : value);
3421
}}
35-
defaultValue={
36-
typeof defaultValue === 'object' ? defaultValue[0] : defaultValue
37-
}
22+
defaultValue={typeof defaultValue === 'object' ? defaultValue[0] : defaultValue}
3823
className="w-full h-[32px] px-2 bg-TRANSPARENT text-I2 max-TBL:text-I4 text-TEXT-MAIN cursor-pointer relative z-40"
3924
>
4025
{options.map((i, j) => (
41-
<option key={j}>{typeof i === 'object' ? i[0] : i}</option>
26+
<option key={j} className="bg-BG-SUB">
27+
{typeof i === 'object' ? i[0] : i}
28+
</option>
4229
))}
4330
</select>
4431
<div className="w-0 h-0 border-[4px] border-TRANSPARENT border-t-BORDER-SUB absolute top-[15px] right-2" />

0 commit comments

Comments
 (0)
Please sign in to comment.