Skip to content

feat(select): scroll buttons #7649

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

Merged
merged 2 commits into from
Apr 24, 2025
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
1 change: 0 additions & 1 deletion apps/site/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ const nextConfig = {
'@radix-ui/react-accessible-icon',
'@radix-ui/react-dropdown-menu',
'@radix-ui/react-label',
'@radix-ui/react-scroll-area',
'@radix-ui/react-select',
'@radix-ui/react-slot',
'@radix-ui/react-tabs',
Expand Down
32 changes: 0 additions & 32 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions packages/ui-components/Common/Select/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,11 @@
rounded;
}
}

.scrollIcon {
@apply mx-auto
my-1
size-4
text-neutral-700
dark:text-neutral-200;
}
7 changes: 7 additions & 0 deletions packages/ui-components/Common/Select/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ export const WithoutLabel: Story = {
},
};

export const WithScrollButtons: Story = {
args: {
values: Array.from({ length: 100 }, (_, i) => `Item ${i}`),
defaultValue: 'Item 50',
},
};

export const DropdownLabel: Story = {
args: {
values: [
Expand Down
22 changes: 10 additions & 12 deletions packages/ui-components/Common/Select/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use client';

import { ChevronDownIcon } from '@heroicons/react/24/outline';
import * as ScrollPrimitive from '@radix-ui/react-scroll-area';
import { ChevronDownIcon, ChevronUpIcon } from '@heroicons/react/24/outline';
import * as SelectPrimitive from '@radix-ui/react-select';
import classNames from 'classnames';
import { useEffect, useId, useMemo, useState } from 'react';
Expand Down Expand Up @@ -168,16 +167,15 @@ const Select = <T extends string>({
[styles.inline]: inline,
})}
>
<ScrollPrimitive.Root type="auto">
<SelectPrimitive.Viewport>
<ScrollPrimitive.Viewport>
{memoizedMappedValues}
</ScrollPrimitive.Viewport>
</SelectPrimitive.Viewport>
<ScrollPrimitive.Scrollbar orientation="vertical">
<ScrollPrimitive.Thumb />
</ScrollPrimitive.Scrollbar>
</ScrollPrimitive.Root>
<SelectPrimitive.ScrollUpButton>
<ChevronUpIcon className={styles.scrollIcon} />
</SelectPrimitive.ScrollUpButton>
<SelectPrimitive.Viewport>
{memoizedMappedValues}
</SelectPrimitive.Viewport>
<SelectPrimitive.ScrollDownButton>
<ChevronDownIcon className={styles.scrollIcon} />
</SelectPrimitive.ScrollDownButton>
</SelectPrimitive.Content>
</SelectPrimitive.Portal>
</SelectPrimitive.Root>
Expand Down
1 change: 0 additions & 1 deletion packages/ui-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"@radix-ui/react-dialog": "^1.1.7",
"@radix-ui/react-dropdown-menu": "~2.1.6",
"@radix-ui/react-label": "~2.1.2",
"@radix-ui/react-scroll-area": "~1.2.3",
"@radix-ui/react-select": "~2.1.6",
"@radix-ui/react-tabs": "~1.1.3",
"@radix-ui/react-toast": "~1.2.6",
Expand Down
Loading