Skip to content

Commit

Permalink
Revert "fix: dropdowns should have a max-height & padding from screen (
Browse files Browse the repository at this point in the history
…#8055)"

This reverts commit e648d94.
  • Loading branch information
martmull authored Oct 29, 2024
1 parent a725245 commit d6a964c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import {
FloatingPortal,
offset,
Placement,
size,
useFloating,
} from '@floating-ui/react';
import { MouseEvent, useEffect, useRef, useState } from 'react';
import { MouseEvent, useEffect, useRef } from 'react';
import { Keys } from 'react-hotkeys-hook';
import { Key } from 'ts-key-enum';

Expand All @@ -22,7 +21,6 @@ import { isDefined } from '~/utils/isDefined';
import { useDropdown } from '../hooks/useDropdown';
import { useInternalHotkeyScopeManagement } from '../hooks/useInternalHotkeyScopeManagement';

import { flushSync } from 'react-dom';
import { DropdownMenu } from './DropdownMenu';
import { DropdownOnToggleEffect } from './DropdownOnToggleEffect';

Expand Down Expand Up @@ -65,9 +63,6 @@ export const Dropdown = ({
onOpen,
}: DropdownProps) => {
const containerRef = useRef<HTMLDivElement>(null);
const [maxHeight, setMaxHeight] = useState<string | number | undefined>(
undefined,
);

const {
isDropdownOpen,
Expand All @@ -89,16 +84,7 @@ export const Dropdown = ({

const { refs, floatingStyles, placement } = useFloating({
placement: dropdownPlacement,
middleware: [
flip(),
size({
padding: 12 + 20, // 12px for padding bottom, 20px for dropdown bottom margin target
apply: ({ availableHeight }) => {
flushSync(() => setMaxHeight(availableHeight));
},
}),
...offsetMiddlewares,
],
middleware: [flip(), ...offsetMiddlewares],
whileElementsMounted: autoUpdate,
strategy: dropdownStrategy,
});
Expand Down Expand Up @@ -169,7 +155,7 @@ export const Dropdown = ({
width={dropdownMenuWidth ?? dropdownWidth}
data-select-disable
ref={refs.setFloating}
style={{ ...floatingStyles, maxHeight }}
style={floatingStyles}
>
{dropdownComponents}
</DropdownMenu>
Expand All @@ -181,7 +167,7 @@ export const Dropdown = ({
width={dropdownMenuWidth ?? dropdownWidth}
data-select-disable
ref={refs.setFloating}
style={{ ...floatingStyles, maxHeight }}
style={floatingStyles}
>
{dropdownComponents}
</DropdownMenu>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ const StyledDropdownMenu = styled.div<{
flex-direction: column;
z-index: 30;
overflow-y: scroll;
overflow-x: hidden;
width: ${({ width = 160 }) =>
typeof width === 'number' ? `${width}px` : width};
`;
Expand Down

0 comments on commit d6a964c

Please sign in to comment.