canonical / canonical/vanilla-framework

Add support for scrollable dropdowns

Open
#4,864 3 comments 0 reactions 0 assignees View on GitHub
P3 Triaged Review: Code needed Triaged: Pragma WG: Validated
Dominant language
HTML
Stars
983
Forks
216
Avg merge
3d 13h
Merged PRs (30d)
3

Description

## Pattern to amend

- Contextual menu
- Search and filter
- Any other dropdowns

## Visual

Screenshot 2023-08-29 at 12 31 09 pm

![Screen Recording 2023-03-20 at 4 27 18 pm](https://user-images.githubusercontent.com/361637/226262184-8c78af15-b3dd-411c-b951-0979664d797f.gif)

## Context

Dropdowns that don't fit on the screen can break the layout (this is especially an issue for the application layout in combination with React portals). This can be fixed by adjusting the dropdown to scroll instead of overflowing the screen, however this is a fix that requires JavaScript to implement.

To support this a max-height is calculated and also a min-height is applied as well as `overflow: auto`.

The implementation for the search and filter and contextual menu dropdowns can be seen here:
- https://github.com/canonical/react-components/pull/906
- https://github.com/canonical/react-components/pull/961

From this comment: https://github.com/canonical/react-components/pull/961#issuecomment-1697397844 it would be good to provide some level of support for this in Vanilla so that it doesn't get broken if these components are updated.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the Contextual menu, Search and filter, and other dropdown patterns, then compare the implementations described in pull requests 906 and 961. Done means Vanilla provides scrollable dropdown support that prevents oversized menus from overflowing the screen without breaking existing patterns.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, javascript, sass
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.