Skip to content

[EuiContextMenu] Make content scrollable for large lists #8803

@weronikaolejniczak

Description

@weronikaolejniczak

Problem Statement

If EuiContextMenu renders a lot of items, it can grow too large and it might be desirable to limit its height and make it scrollable. It's possible through applying useEuiOverflowScroll alongside max-height:

Image

Proposed Solution

The idea is to add a flag to EuiContextMenu that controls whether the content can be scrolled or not (or in other words have max height), and applies appropriate styles to the content element.

Use Case

Value / Impact

  • It seems valuable both for end-users and to library consumers.
  • It could potentially become a pattern for scrollable context menus.

Urgency

It is not a blocker for a large initiative. There is a known workaround.

Do alternatives or workarounds exist?

Currently, it requires targeting an underlying base class and applying background property with !important flag. Codesandbox

<EuiContextMenu
  initialPanelId={0}
  css={css`
    .euiContextMenuPanel > div:not(.euiContextMenuPanel__title) {
       max-height: 10rem;
      ${useEuiOverflowScroll("y")}
    }
  `}
  panels={panels}
>

Related code or customizations

Metadata

Metadata

Assignees

No one assigned

    Labels

    design decisionUse this to flag an item that needs input from the design team

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions