Skip to content

Commit b55fc58

Browse files
fix(ui/Select): fix styling for menu part
1 parent b6be86d commit b55fc58

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

src/components/ui/Select/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import ReactSelect, { ActionMeta, GroupBase, Props } from "react-select"
1+
import ReactSelect, {
2+
type ActionMeta,
3+
type GroupBase,
4+
type Props,
5+
} from "react-select"
26

37
import {
48
components,

src/components/ui/Select/innerComponents.tsx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type {
77
GroupBase,
88
GroupProps,
99
MenuListProps,
10+
MenuProps,
1011
OptionProps,
1112
} from "react-select"
1213
import { tv, type VariantProps } from "tailwind-variants"
@@ -16,11 +17,12 @@ import { cn } from "@/lib/utils/cn"
1617
export const selectVariants = tv({
1718
slots: {
1819
container:
19-
"w-full min-h-10.5 [--border-base-width:1px] relative z-[1] [&_>_.react-select\\_\\_menu]:-z-[1] cursor-pointer",
20+
"w-full min-h-10.5 [--border-base-width:1px] relative z-[1] cursor-pointer",
2021
control:
2122
"p-2 flex items-center gap-4 border-[length:var(--border-base-width)] border-current text-[color:var(--my-var)] not-[[data-expanded=true]]:focus-within:outline-3 not-[[data-expanded=true]]:focus-within:outline-primary-hover not-[[data-expanded=true]]:focus-within:outline -outline-offset-2 [&[data-expanded=true]]:bg-background-highlight [&[data-expanded=true]]:text-primary [&[data-expanded=true]]:border-primary-low-contrast hover:text-primary hover:border-primary-low-contrast",
2223
indicatorIcon:
2324
"text-sm leading-none transition-transform [*[data-expanded=true]_&]:rotate-180",
25+
menu: "-z-[1] relative",
2426
menuList:
2527
"overflow-y-auto bg-background-highlight w-full max-h-80 border-x-[length:--border-base-width] border-b-[length:--border-base-width] rounded-b",
2628
option:
@@ -129,6 +131,29 @@ const DropdownIndicator = <
129131
</div>
130132
)
131133
}
134+
135+
const Menu = <
136+
Option,
137+
IsMulti extends boolean,
138+
Group extends GroupBase<Option>,
139+
>({
140+
children,
141+
innerProps,
142+
innerRef,
143+
}: MenuProps<Option, IsMulti, Group>) => {
144+
const { menu } = useSelectStyles()
145+
return (
146+
<div
147+
ref={innerRef}
148+
className={menu()}
149+
id="react-select-menu"
150+
{...innerProps}
151+
>
152+
{children}
153+
</div>
154+
)
155+
}
156+
132157
const MenuList = <
133158
Option,
134159
IsMulti extends boolean,
@@ -216,6 +241,7 @@ export const components = {
216241
// Essentially removes this component from default render
217242
IndicatorSeparator: nullop,
218243
DropdownIndicator,
244+
Menu,
219245
MenuList,
220246
Option,
221247
Group,

0 commit comments

Comments
 (0)