(null);
+ if (dropdownRef) {
+ targetRef = dropdownRef;
+ }
+
+ const [showOverflow, setShowOverflow] = useState(false);
+
useLayoutEffect(() => {
const container = current?.children.item(0);
if (container) {
@@ -214,7 +225,7 @@ const DropdownContainer = forwardRef(
const popoverContent = useMemo(
() =>
- getPopoverContent || overflowingCount ? (
+ dropdownContent || overflowingCount ? (
- {getPopoverContent
- ? getPopoverContent(overflowedItems)
+ {dropdownContent
+ ? dropdownContent(overflowedItems)
: overflowedItems.map(item => item.element)}
) : null,
[
- getPopoverContent,
- overflowedItems,
+ dropdownContent,
overflowingCount,
- popoverRef,
- popoverStyle,
theme.gridUnit,
+ dropdownStyle,
+ overflowedItems,
],
);
+ useLayoutEffect(() => {
+ if (popoverVisible) {
+ // Measures scroll height after rendering the elements
+ setTimeout(() => {
+ if (targetRef.current) {
+ // We only set overflow when there's enough space to display
+ // Select's popovers because they are restrained by the overflow property.
+ setShowOverflow(targetRef.current.scrollHeight > MAX_HEIGHT);
+ }
+ }, 100);
+ }
+ }, [popoverVisible]);
+
useImperativeHandle(
outerRef,
() => ({
@@ -271,35 +294,63 @@ const DropdownContainer = forwardRef(
{notOverflowedItems.map(item => item.element)}
{popoverContent && (
- setPopoverVisible(visible)}
- placement="bottom"
- >
-
-
+ ::-webkit-scrollbar-thumb {
+ border-radius: 9px;
+ background-color: ${theme.colors.grayscale.light1};
+ border: 3px solid transparent;
+ background-clip: content-box;
+ }
+ ::-webkit-scrollbar-track {
+ background-color: ${theme.colors.grayscale.light4};
+ border-left: 1px solid ${theme.colors.grayscale.light2};
+ }
+ }
+ `}
+ />
+ setPopoverVisible(visible)}
+ placement="bottom"
+ >
+
+
+ >
)}
);