Skip to content

Commit c0484aa

Browse files
fix: dropdown max-height and padding bottom (#8167)
Fixes: #6105 Also fixed side effect due to previous PR: [Screencast from 2024-10-29 13-54-44.webm](https://github.com/user-attachments/assets/f15db853-ca1c-4be8-9362-610122c4d988)
1 parent f79e904 commit c0484aa

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

packages/twenty-front/src/modules/ui/layout/dropdown/components/Dropdown.tsx

+14-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
FloatingPortal,
55
offset,
66
Placement,
7+
size,
78
useFloating,
89
} from '@floating-ui/react';
910
import { MouseEvent, useEffect, useRef } from 'react';
@@ -85,7 +86,19 @@ export const Dropdown = ({
8586

8687
const { refs, floatingStyles, placement } = useFloating({
8788
placement: dropdownPlacement,
88-
middleware: [flip(), ...offsetMiddlewares],
89+
middleware: [
90+
flip(),
91+
size({
92+
padding: 12 + 20, // 12px for padding bottom, 20px for dropdown bottom margin target
93+
apply: ({ availableHeight, elements }) => {
94+
elements.floating.style.maxHeight =
95+
availableHeight >= elements.floating.scrollHeight
96+
? ''
97+
: `${availableHeight}px`;
98+
},
99+
}),
100+
...offsetMiddlewares,
101+
],
89102
whileElementsMounted: autoUpdate,
90103
strategy: dropdownStrategy,
91104
});

packages/twenty-front/src/modules/ui/layout/dropdown/components/DropdownMenu.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ const StyledDropdownMenu = styled.div<{
2525
2626
flex-direction: column;
2727
z-index: 30;
28+
overflow-y: auto;
29+
overflow-x: hidden;
2830
width: ${({ width = 160 }) =>
2931
typeof width === 'number' ? `${width}px` : width};
3032
`;

0 commit comments

Comments
 (0)