mirror of
https://github.com/lingble/twenty.git
synced 2025-11-01 21:27:58 +00:00
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)
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
|||||||
FloatingPortal,
|
FloatingPortal,
|
||||||
offset,
|
offset,
|
||||||
Placement,
|
Placement,
|
||||||
|
size,
|
||||||
useFloating,
|
useFloating,
|
||||||
} from '@floating-ui/react';
|
} from '@floating-ui/react';
|
||||||
import { MouseEvent, useEffect, useRef } from 'react';
|
import { MouseEvent, useEffect, useRef } from 'react';
|
||||||
@@ -85,7 +86,19 @@ export const Dropdown = ({
|
|||||||
|
|
||||||
const { refs, floatingStyles, placement } = useFloating({
|
const { refs, floatingStyles, placement } = useFloating({
|
||||||
placement: dropdownPlacement,
|
placement: dropdownPlacement,
|
||||||
middleware: [flip(), ...offsetMiddlewares],
|
middleware: [
|
||||||
|
flip(),
|
||||||
|
size({
|
||||||
|
padding: 12 + 20, // 12px for padding bottom, 20px for dropdown bottom margin target
|
||||||
|
apply: ({ availableHeight, elements }) => {
|
||||||
|
elements.floating.style.maxHeight =
|
||||||
|
availableHeight >= elements.floating.scrollHeight
|
||||||
|
? ''
|
||||||
|
: `${availableHeight}px`;
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
...offsetMiddlewares,
|
||||||
|
],
|
||||||
whileElementsMounted: autoUpdate,
|
whileElementsMounted: autoUpdate,
|
||||||
strategy: dropdownStrategy,
|
strategy: dropdownStrategy,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ const StyledDropdownMenu = styled.div<{
|
|||||||
|
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
z-index: 30;
|
z-index: 30;
|
||||||
|
overflow-y: auto;
|
||||||
|
overflow-x: hidden;
|
||||||
width: ${({ width = 160 }) =>
|
width: ${({ width = 160 }) =>
|
||||||
typeof width === 'number' ? `${width}px` : width};
|
typeof width === 'number' ? `${width}px` : width};
|
||||||
`;
|
`;
|
||||||
|
|||||||
Reference in New Issue
Block a user