Skip to content

Commit 4b224d5

Browse files
fix: fix onScroll in Select.Content (medusajs#12855)
Radix' `Select.Content` is not the scrollable div. It's `Select.Viewport`, which we don't expose. onScroll is useful when the elements in the select are loaded in infinite loading style. Co-authored-by: Oli Juhl <[email protected]>
1 parent 95d282e commit 4b224d5

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

.changeset/spotty-ears-end.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@medusajs/ui": patch
3+
---
4+
5+
fix: fix onScroll in Select.Content

packages/design-system/ui/src/components/select/select.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ const Trigger = React.forwardRef<
105105
})
106106
Trigger.displayName = "Select.Trigger"
107107

108-
interface SelectContentProps extends React.ComponentPropsWithoutRef<typeof RadixSelect.Content> {
109-
}
108+
interface SelectContentProps
109+
extends React.ComponentPropsWithoutRef<typeof RadixSelect.Content> {}
110110

111111
/**
112112
* The content that appears when the select is open.
@@ -120,6 +120,7 @@ const Content = React.forwardRef<
120120
{
121121
className,
122122
children,
123+
onScroll,
123124
/**
124125
* Whether to show the select items below (`popper`) or over (`item-aligned`) the select input.
125126
*/
@@ -161,6 +162,7 @@ const Content = React.forwardRef<
161162
position === "popper" &&
162163
"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
163164
)}
165+
onScroll={onScroll}
164166
>
165167
{children}
166168
</RadixSelect.Viewport>
@@ -201,7 +203,7 @@ const Item = React.forwardRef<
201203
<RadixSelect.Item
202204
ref={ref}
203205
className={clx(
204-
"bg-ui-bg-component grid cursor-pointer grid-cols-[15px_1fr] gap-x-2 rounded-[4px] px-2 py-1.5 outline-none transition-colors txt-compact-small items-center",
206+
"bg-ui-bg-component txt-compact-small grid cursor-pointer grid-cols-[15px_1fr] items-center gap-x-2 rounded-[4px] px-2 py-1.5 outline-none transition-colors",
205207
"focus-visible:bg-ui-bg-component-hover",
206208
"active:bg-ui-bg-component-pressed",
207209
"data-[state=checked]:txt-compact-small-plus",
@@ -229,7 +231,10 @@ const Separator = React.forwardRef<
229231
>(({ className, ...props }, ref) => (
230232
<RadixSelect.Separator
231233
ref={ref}
232-
className={clx("bg-ui-border-component -mx-1 my-1 h-0.5 border-t border-t-ui-border-menu-top border-b border-b-ui-border-menu-bot", className)}
234+
className={clx(
235+
"bg-ui-border-component border-t-ui-border-menu-top border-b-ui-border-menu-bot -mx-1 my-1 h-0.5 border-b border-t",
236+
className
237+
)}
233238
{...props}
234239
/>
235240
))

0 commit comments

Comments
 (0)