Skip to content

Commit e9597d0

Browse files
authored
fix: add scrollbar to combobox (#1879)
### What does it do? Added `ScrollArea`. ### Why is it needed? See #1858. ### How to test it? You'll need to check the preview. ### Related issue(s)/PR(s) #1858 #1859
2 parents 909d3a0 + 4e7d782 commit e9597d0

File tree

2 files changed

+35
-27
lines changed

2 files changed

+35
-27
lines changed

.changeset/rich-papayas-fry.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@strapi/design-system': patch
3+
---
4+
5+
fix: add scrollbar to combobox

packages/design-system/src/components/Combobox/Combobox.tsx

+30-27
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { Flex } from '../../primitives/Flex';
1414
import { Typography } from '../../primitives/Typography';
1515
import { ANIMATIONS } from '../../styles/motion';
1616
import { inputFocusStyle } from '../../themes';
17+
import { ScrollArea } from '../../utilities/ScrollArea';
1718
import { Field, useField } from '../Field';
1819
import { Loader } from '../Loader';
1920

@@ -264,33 +265,35 @@ const Combobox = React.forwardRef<ComboboxInputElement, ComboboxProps>(
264265
</Trigger>
265266
<ComboboxPrimitive.Portal>
266267
<Content sideOffset={4}>
267-
<Viewport ref={viewportRef}>
268-
{children}
269-
{creatable ? (
270-
<ComboboxPrimitive.CreateItem
271-
onPointerUp={handleCreateItemClick}
272-
onClick={handleCreateItemClick}
273-
asChild
274-
>
275-
<OptionBox>
276-
<Typography>{createMessage(internalTextValue ?? '')}</Typography>
277-
</OptionBox>
278-
</ComboboxPrimitive.CreateItem>
279-
) : null}
280-
{!creatable && !loading ? (
281-
<ComboboxPrimitive.NoValueFound asChild>
282-
<OptionBox $hasHover={false}>
283-
<Typography>{noOptionsMessage(internalTextValue ?? '')}</Typography>
284-
</OptionBox>
285-
</ComboboxPrimitive.NoValueFound>
286-
) : null}
287-
{loading ? (
288-
<Flex justifyContent="center" alignItems="center" paddingTop={2} paddingBottom={2}>
289-
<Loader small>{loadingMessage}</Loader>
290-
</Flex>
291-
) : null}
292-
<Box id={intersectionId} width="100%" height="1px" />
293-
</Viewport>
268+
<ScrollArea>
269+
<Viewport ref={viewportRef}>
270+
{children}
271+
{creatable ? (
272+
<ComboboxPrimitive.CreateItem
273+
onPointerUp={handleCreateItemClick}
274+
onClick={handleCreateItemClick}
275+
asChild
276+
>
277+
<OptionBox>
278+
<Typography>{createMessage(internalTextValue ?? '')}</Typography>
279+
</OptionBox>
280+
</ComboboxPrimitive.CreateItem>
281+
) : null}
282+
{!creatable && !loading ? (
283+
<ComboboxPrimitive.NoValueFound asChild>
284+
<OptionBox $hasHover={false}>
285+
<Typography>{noOptionsMessage(internalTextValue ?? '')}</Typography>
286+
</OptionBox>
287+
</ComboboxPrimitive.NoValueFound>
288+
) : null}
289+
{loading ? (
290+
<Flex justifyContent="center" alignItems="center" paddingTop={2} paddingBottom={2}>
291+
<Loader small>{loadingMessage}</Loader>
292+
</Flex>
293+
) : null}
294+
<Box id={intersectionId} width="100%" height="1px" />
295+
</Viewport>
296+
</ScrollArea>
294297
</Content>
295298
</ComboboxPrimitive.Portal>
296299
</ComboboxPrimitive.Root>

0 commit comments

Comments
 (0)