Skip to content

Commit

Permalink
Merge pull request #71 from NeuroNexul/fix/scroll
Browse files Browse the repository at this point in the history
Fix/scroll: Fixed visual glitch in Scrollable Select Component
  • Loading branch information
ruru-m07 authored Sep 19, 2024
2 parents 4b6070a + 3b8d236 commit bbf4024
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
4 changes: 0 additions & 4 deletions apps/www/components/selectLargeData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import {
SelectGroup,
SelectItem,
SelectLabel,
SelectScrollDownButton,
SelectScrollUpButton,
SelectSeparator,
} from "ruru-ui/components/select";

Expand All @@ -22,13 +20,11 @@ const SelectCountries = () => {
<SelectGroup>
<SelectLabel>Fruits</SelectLabel>
<SelectSeparator />
<SelectScrollUpButton />
{Array.from({ length: 50 }, (_, index) => (
<SelectItem key={index} value={String(index)}>
Ruru-UI-V{index}
</SelectItem>
))}
<SelectScrollDownButton />
</SelectGroup>
</SelectContent>
</Select>
Expand Down
10 changes: 2 additions & 8 deletions apps/www/content/docs/components/select.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -257,18 +257,16 @@ export function DefaultValueSelect() {
</Tab>
</Tabs>

### ScrollDownButton and ScrollUpButton
### Scrollable

You can add scroll buttons to the `Select` component by using the `SelectScrollDownButton` and `SelectScrollUpButton` components.
When the content in the Select component exceeds the maximum height, it becomes scrollable, adding `ScrollUpButton` and `ScrollDownButton` to help users easily navigate through the options.

<Tabs items={["Preview", "Code"]}>
<Tab className={"flex justify-center"} value="Preview">
<SelectCountries />
</Tab>
<Tab className={"-mt-8"} value="Code">
```tsx
// [!code word:SelectScrollDownButton]
// [!code word:SelectScrollUpButton]
import {
Select,
SelectContent,
Expand All @@ -277,8 +275,6 @@ import {
SelectGroup,
SelectItem,
SelectLabel,
SelectScrollDownButton,
SelectScrollUpButton,
SelectSeparator,
} from "ruru-ui/components/select";
Expand All @@ -293,13 +289,11 @@ const SelectCountries = () => {
<SelectGroup>
<SelectLabel>Fruits</SelectLabel>
<SelectSeparator />
<SelectScrollUpButton />
{Array.from({ length: 50 }, (_, index) => (
<SelectItem key={index} value={String(index)}>
Ruru-UI-V{index}
</SelectItem>
))}
<SelectScrollDownButton />
</SelectGroup>
</SelectContent>
</Select>
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/components/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const SelectScrollUpButton = React.forwardRef<
<SelectPrimitive.ScrollUpButton
ref={ref}
className={cn(
"flex cursor-default items-center justify-center py-1",
"flex cursor-default items-center justify-center py-1 w-full absolute top-0 bg-popover z-10",
className,
)}
{...props}
Expand All @@ -138,7 +138,7 @@ const SelectScrollDownButton = React.forwardRef<
<SelectPrimitive.ScrollDownButton
ref={ref}
className={cn(
"flex cursor-default items-center justify-center py-1",
"flex cursor-default items-center justify-center py-1 w-full absolute bottom-0 bg-popover z-10",
className,
)}
{...props}
Expand Down

0 comments on commit bbf4024

Please sign in to comment.