Skip to content

Commit 6460a18

Browse files
committed
refactor(combobox): remove useMenuStyle, let menu shrink and scroll when space
is tight
1 parent 04161d5 commit 6460a18

2 files changed

Lines changed: 10 additions & 45 deletions

File tree

packages/pluggableWidgets/combobox-web/src/hooks/useMenuStyle.ts

Lines changed: 0 additions & 39 deletions
This file was deleted.

packages/pluggableWidgets/combobox-web/src/ui/Combobox.scss

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ $cb-skeleton-dark: #d2d2d2;
2323
position: relative;
2424
transition: color 150ms ease 0s;
2525
&-menu {
26-
position: absolute;
27-
display: inline;
26+
// Positioning (top/left/width/max-height) is applied inline by floating-ui.
27+
// The wrapper is a flex column so its children (header, scrolling list, footer)
28+
// share the height cap floating-ui sets when space is tight.
29+
display: flex;
30+
flex-direction: column;
2831
border-radius: var(--dropdown-border-radius, $cb-menu-border-radius);
29-
margin: var(--spacing-smaller, $cb-spacing) 0 var(--spacing-smaller, $cb-spacing) 0;
30-
width: 100%;
31-
left: unset;
3232
padding: var(--dropdown-outer-padding, $cb-menu-outer-padding) 0 0;
3333
z-index: 25;
3434
box-shadow: 0px 0px var(--dropdown-outer-padding, $cb-menu-outer-padding) 0px
@@ -38,7 +38,11 @@ $cb-skeleton-dark: #d2d2d2;
3838
&-list {
3939
padding: 0;
4040
margin-bottom: 0;
41-
max-height: 320px;
41+
// Fill the (possibly shrunk) wrapper and scroll internally, instead of a
42+
// fixed cap that would overflow the wrapper when floating-ui shrinks it.
43+
flex: 1;
44+
min-height: 0;
45+
max-height: 100%;
4246
overflow-y: auto;
4347
&:last-child {
4448
margin-bottom: var(--dropdown-outer-padding, $cb-menu-outer-padding);

0 commit comments

Comments
 (0)