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/scroll: Fixed visual glitch in Scrollable Select Component #71

Merged
merged 2 commits into from
Sep 19, 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
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
ruru-m07 marked this conversation as resolved.
Show resolved Hide resolved
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