fix: relation picker should not move once openened (#8026)

Fixes: #7959 

### Problem
- When searching in the dropdown, the results list would shrink based on
matching items
- This dynamic height change caused the dropdown to flip its position on
each keystroke

### Solution
- Added ```hasMinHeight``` as optional props to the
```DropdownMenuItemsContainer``` to maintain consistent height
- This prevents unwanted position recalculations and flipping while user
types
- The dropdown now stays in its initial position throughout the search
interaction

[Screencast from 2024-10-24
15-43-03.webm](https://github.com/user-attachments/assets/741317b7-fc5e-4874-8221-aa626a1a1747)
This commit is contained in:
Harsh Singh 2024-10-24 20:03:50 +05:30 committed by GitHub
parent 4ceee4ab8f
commit 4e8d8ce744
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View File

@ -113,7 +113,7 @@ export const MultiRecordSelect = ({
autoFocus autoFocus
/> />
<DropdownMenuSeparator /> <DropdownMenuSeparator />
<DropdownMenuItemsContainer hasMaxHeight> <DropdownMenuItemsContainer hasMaxHeight hasMinHeight>
{recordMultiSelectIsLoading ? ( {recordMultiSelectIsLoading ? (
<MenuItem text="Loading..." /> <MenuItem text="Loading..." />
) : ( ) : (

View File

@ -3,6 +3,7 @@ import styled from '@emotion/styled';
import { ScrollWrapper } from '@/ui/utilities/scroll/components/ScrollWrapper'; import { ScrollWrapper } from '@/ui/utilities/scroll/components/ScrollWrapper';
const StyledDropdownMenuItemsExternalContainer = styled.div<{ const StyledDropdownMenuItemsExternalContainer = styled.div<{
hasMinHeight?: boolean;
hasMaxHeight?: boolean; hasMaxHeight?: boolean;
}>` }>`
--padding: ${({ theme }) => theme.spacing(1)}; --padding: ${({ theme }) => theme.spacing(1)};
@ -12,7 +13,7 @@ const StyledDropdownMenuItemsExternalContainer = styled.div<{
flex-direction: column; flex-direction: column;
gap: 2px; gap: 2px;
height: 100%; min-height: ${({ hasMinHeight }) => (hasMinHeight ? '150px' : '100%')};
max-height: ${({ hasMaxHeight }) => (hasMaxHeight ? '188px' : 'none')}; max-height: ${({ hasMaxHeight }) => (hasMaxHeight ? '188px' : 'none')};
overflow-y: auto; overflow-y: auto;
@ -37,13 +38,18 @@ const StyledDropdownMenuItemsInternalContainer = styled.div`
export const DropdownMenuItemsContainer = ({ export const DropdownMenuItemsContainer = ({
children, children,
hasMinHeight,
hasMaxHeight, hasMaxHeight,
}: { }: {
children: React.ReactNode; children: React.ReactNode;
hasMinHeight?: boolean;
hasMaxHeight?: boolean; hasMaxHeight?: boolean;
}) => { }) => {
return ( return (
<StyledDropdownMenuItemsExternalContainer hasMaxHeight={hasMaxHeight}> <StyledDropdownMenuItemsExternalContainer
hasMaxHeight={hasMaxHeight}
hasMinHeight={hasMinHeight}
>
{hasMaxHeight ? ( {hasMaxHeight ? (
<StyledScrollWrapper contextProviderName="dropdownMenuItemsContainer"> <StyledScrollWrapper contextProviderName="dropdownMenuItemsContainer">
<StyledDropdownMenuItemsInternalContainer> <StyledDropdownMenuItemsInternalContainer>