Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: select component wouldn't scroll with long list #757

Merged
merged 2 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/late-roses-fly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bigcommerce/catalyst-core": patch
---

Update cart select components to use the item-aligned select content in order to scroll with large Select content.
5 changes: 5 additions & 0 deletions .changeset/three-hairs-nail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bigcommerce/components": patch
---

Update styles to scroll when Select content is long.
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export const ShippingInfo = ({
placeholder={t('countryPlaceholder')}
value={formValues.country}
>
<SelectContent>
<SelectContent position="item-aligned">
{shippingCountries.map(({ id, countryCode, name }) => {
return (
<SelectItem key={id} value={`${countryCode}-${id}`}>
Expand All @@ -179,7 +179,7 @@ export const ShippingInfo = ({
placeholder={t('statePlaceholder')}
value={formValues.state}
>
<SelectContent>
<SelectContent position="item-aligned">
{formValues.states.map(({ id, state }) => {
return (
<SelectItem key={id} value={state}>
Expand Down
16 changes: 12 additions & 4 deletions packages/components/src/components/select/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,27 @@ type SelectContentType = typeof SelectPrimitive.Content;
const SelectContent = forwardRef<
ElementRef<SelectContentType>,
ComponentPropsWithRef<SelectContentType>
>(({ children, className, ...props }, ref) => {
>(({ children, className, position = 'popper', ...props }, ref) => {
return (
<SelectPrimitive.Portal>
<SelectPrimitive.Content
position="popper"
position={position}
{...props}
className={cn(
'max-h-radix-select-content-available-height relative w-full bg-white shadow-md data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',
'max-h-radix-select-content-available-height relative w-full bg-white shadow-md',
position === 'popper' &&
'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',
className,
)}
ref={ref}
>
<SelectPrimitive.Viewport className="h-radix-select-content-available-height w-full min-w-[var(--radix-select-trigger-width)]">
<SelectPrimitive.Viewport
className={cn(
'w-full',
position === 'popper' &&
'h-[var(--radix-select-trigger-height)] min-w-[var(--radix-select-trigger-width)]',
)}
>
{children}
</SelectPrimitive.Viewport>
</SelectPrimitive.Content>
Expand Down
Loading