Skip to content

Commit d0f7929

Browse files
authored
fix: scrollbar is not visible; scrollarea is not wholly clickable (#1974)
2 parents 4ec57a0 + 48c79ba commit d0f7929

File tree

2 files changed

+54
-54
lines changed

2 files changed

+54
-54
lines changed

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

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -292,47 +292,49 @@ const Combobox = React.forwardRef<ComboboxInputElement, ComboboxProps>(
292292
</Trigger>
293293
<ComboboxPrimitive.Portal>
294294
<Content sideOffset={4}>
295-
<ComboboxPrimitive.Viewport ref={viewportRef}>
296-
<ScrollAreaCombobox>
297-
{shouldVirtualizeOptions ? (
298-
<VirtualizedList itemCount={childrenCount}>{children}</VirtualizedList>
299-
) : (
300-
children
301-
)}
302-
{creatable !== true && !loading ? (
303-
<ComboboxPrimitive.NoValueFound asChild>
304-
<OptionBox $hasHover={false}>
305-
<Typography>{noOptionsMessage(internalTextValue ?? '')}</Typography>
306-
</OptionBox>
307-
</ComboboxPrimitive.NoValueFound>
308-
) : null}
309-
{loading ? (
310-
<Flex justifyContent="center" alignItems="center" paddingTop={2} paddingBottom={2}>
311-
<Loader small>{loadingMessage}</Loader>
312-
</Flex>
313-
) : null}
314-
<Box id={intersectionId} width="100%" height="1px" />
315-
</ScrollAreaCombobox>
316-
{creatable ? (
317-
<ComboboxCreateItem
318-
onPointerUp={handleCreateItemClick}
319-
onClick={handleCreateItemClick}
320-
disabled={creatableDisabled}
321-
asChild
322-
>
323-
<OptionBox>
324-
<Flex gap={2}>
325-
{creatableStartIcon && (
326-
<Box tag="span" aria-hidden display={'inline-flex'}>
327-
{creatableStartIcon}
328-
</Box>
329-
)}
330-
<Typography>{createMessage(internalTextValue ?? '')}</Typography>
295+
<ScrollArea>
296+
<ComboboxPrimitive.Viewport ref={viewportRef}>
297+
<Box padding={1}>
298+
{shouldVirtualizeOptions ? (
299+
<VirtualizedList itemCount={childrenCount}>{children}</VirtualizedList>
300+
) : (
301+
children
302+
)}
303+
{creatable !== true && !loading ? (
304+
<ComboboxPrimitive.NoValueFound asChild>
305+
<OptionBox $hasHover={false}>
306+
<Typography>{noOptionsMessage(internalTextValue ?? '')}</Typography>
307+
</OptionBox>
308+
</ComboboxPrimitive.NoValueFound>
309+
) : null}
310+
{loading ? (
311+
<Flex justifyContent="center" alignItems="center" paddingTop={2} paddingBottom={2}>
312+
<Loader small>{loadingMessage}</Loader>
331313
</Flex>
332-
</OptionBox>
333-
</ComboboxCreateItem>
334-
) : null}
335-
</ComboboxPrimitive.Viewport>
314+
) : null}
315+
<Box id={intersectionId} width="100%" height="1px" />
316+
</Box>
317+
</ComboboxPrimitive.Viewport>
318+
</ScrollArea>
319+
{creatable ? (
320+
<ComboboxCreateItem
321+
onPointerUp={handleCreateItemClick}
322+
onClick={handleCreateItemClick}
323+
disabled={creatableDisabled}
324+
asChild
325+
>
326+
<OptionBox>
327+
<Flex gap={2}>
328+
{creatableStartIcon && (
329+
<Box tag="span" aria-hidden display={'inline-flex'}>
330+
{creatableStartIcon}
331+
</Box>
332+
)}
333+
<Typography>{createMessage(internalTextValue ?? '')}</Typography>
334+
</Flex>
335+
</OptionBox>
336+
</ComboboxCreateItem>
337+
) : null}
336338
</Content>
337339
</ComboboxPrimitive.Portal>
338340
</ComboboxPrimitive.Root>
@@ -489,10 +491,6 @@ const ComboboxCreateItem = styled(ComboboxPrimitive.CreateItem)`
489491
}
490492
`;
491493

492-
const ScrollAreaCombobox = styled(ScrollArea)`
493-
padding: ${({ theme }) => theme.spaces[1]};
494-
`;
495-
496494
/* -------------------------------------------------------------------------------------------------
497495
* ComboboxOption
498496
* -----------------------------------------------------------------------------------------------*/

packages/design-system/src/utilities/ScrollArea/ScrollArea.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,18 @@ const Thumb = styled(ScrollArea.Thumb)`
6767
border-radius: 0.4rem;
6868
6969
/* increase target size for touch devices https://www.w3.org/WAI/WCAG21/Understanding/target-size.html */
70-
&::before {
71-
content: '';
72-
position: absolute;
73-
top: 50%;
74-
left: 50%;
75-
transform: translate(-50%, -50%);
76-
width: 100%;
77-
height: 100%;
78-
min-width: 44px;
79-
min-height: 44px;
70+
@media (hover: none), (pointer: coarse) {
71+
&::before {
72+
content: '';
73+
position: absolute;
74+
top: 50%;
75+
left: 50%;
76+
transform: translate(-50%, -50%);
77+
width: 100%;
78+
height: 100%;
79+
min-width: 44px;
80+
min-height: 44px;
81+
}
8082
}
8183
`;
8284

0 commit comments

Comments
 (0)