Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dropdowns should have a max-height and a scroll bar #6105

Open
FelixMalfait opened this issue Jul 3, 2024 · 4 comments
Open

Dropdowns should have a max-height and a scroll bar #6105

FelixMalfait opened this issue Jul 3, 2024 · 4 comments
Labels
good for experienced contributor scope: front Issues that are affecting the frontend side only type: bug Something isn't working

Comments

@FelixMalfait
Copy link
Member

I was shadowing a client that had created lots of field and the Filter dropdown was bigger than their screen's height.
We might (or might not?) want to set a max-height.
Also we want to make sure there's a scroll bar upon scroll (when I added a max-height directly in Chrome, the dropdown become scrollable but I couldn't see any scroll bar)

cc @Bonapara for recommandation

@FelixMalfait FelixMalfait added type: bug Something isn't working scope: front Issues that are affecting the frontend side only labels Jul 3, 2024
Copy link

greptile-apps bot commented Jul 3, 2024

To address the issue of dropdowns being larger than the screen height and ensuring a visible scrollbar, follow these steps:

  1. Update DropdownMenuItemsContainer.tsx:
const StyledDropdownMenuItemsExternalContainer = styled.div<{
  hasMaxHeight?: boolean;
}>`
  --padding: ${({ theme }) => theme.spacing(1)};

  align-items: flex-start;
  display: flex;

  flex-direction: column;
  gap: 2px;
  height: 100%;
  max-height: ${({ hasMaxHeight }) => (hasMaxHeight ? '188px' : 'none')};
  overflow-y: auto;
  overflow-y: scroll; /* Ensure scrollbar is visible */

  padding: var(--padding);

  width: calc(100% - 2 * var(--padding));
`;
  1. Update DropdownMenu.tsx:
const StyledDropdownMenu = styled.div<{
  disableBlur?: boolean;
  disableBorder?: boolean;
  width?: `${string}px` | `${number}%` | 'auto' | number;
}>`
  backdrop-filter: ${({ theme, disableBlur }) =>
    disableBlur ? 'none' : theme.blur.medium};

  color: ${({ theme }) => theme.font.color.secondary};

  background: ${({ theme, disableBlur }) =>
    disableBlur
      ? theme.background.primary
      : theme.background.transparent.primary};

  border: ${({ disableBorder, theme }) =>
    disableBorder ? 'none' : `1px solid ${theme.border.color.medium}`};
  border-radius: ${({ theme }) => theme.border.radius.md};

  box-shadow: ${({ theme }) => theme.boxShadow.strong};

  display: flex;

  flex-direction: column;
  z-index: 1;
  width: ${({ width = 160 }) =>
    typeof width === 'number' ? `${width}px` : width};
  max-height: 188px; /* Set max-height */
  overflow-y: auto; /* Ensure scrollbar is visible */
`;

These changes will ensure that the dropdowns have a max-height and a visible scrollbar when the content exceeds the specified height.

References

/packages/twenty-front/src/modules/ui/layout/dropdown/components/DropdownMenuItemsContainer.tsx
/packages/twenty-front/src/modules/ui/layout/dropdown/components/DropdownMenu.tsx
/packages/twenty-front/src/modules/ui/input/components/Select.tsx
/packages/twenty-front/src/modules/ui/layout/dropdown/components/Dropdown.tsx

About Greptile

This response provides a starting point for your research, not a precise solution.

Help us improve! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

Ask Greptile · Edit Issue Bot Settings

@Bonapara
Copy link
Member

Bonapara commented Jul 3, 2024

The max-height should be automatically determined based on the screen height. We should always maintain a minimum 20px bottom margin between the menu and the screen bottom:

image

image

@cooldude6000
Copy link

Is this issue open ? Can i take it?

@Bonapara
Copy link
Member

Bonapara commented Jul 3, 2024

Sure! Thanks for contributing @gowreesh369

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good for experienced contributor scope: front Issues that are affecting the frontend side only type: bug Something isn't working
Projects
Status: 🆕 New
Development

No branches or pull requests

3 participants