Skip to content

Commit

Permalink
fix: the list has too much scroll height when there are few items and…
Browse files Browse the repository at this point in the history
… extra padding (#165)

* feat: remove padding from the popover

make it so that the min-height of the `.items` is the limit height given by `useListbox`

it handles the edgecase where min-height is 150px (default for `virtualize` items)
and the height of the items is smaller than  150px which renders a white scrollable area after the items

* feat: add story to test the min height edge case

* feat: add empty source story

* feat: remove `styleMap`

* feat: remove the new stories
  • Loading branch information
florianstancioiu committed Apr 30, 2024
1 parent 326584f commit 40428f6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/listbox/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ const Listbox = <I>(props: Props<I>) => {
[itemHeight],
);

return html`<div class="items" ${ref((el) => (listRef.current = el))}>
return html`<div
class="items"
${ref((el) => (listRef.current = el))}
style="min-height: ${height}px"
>
<div virtualizer-sizer></div>
${virtualize({
items,
Expand Down
3 changes: 3 additions & 0 deletions src/listbox/style.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ const style = css`
margin: 0;
border: 0;
}
:host([popover]) {
padding: 0;
}
.items {
position: relative;
overflow-y: auto;
Expand Down
1 change: 1 addition & 0 deletions stories/cosmoz-autocomplete.stories.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable max-lines */
import { html } from 'lit-html';
import { styleMap } from 'lit-html/directives/style-map.js';
import { classMap } from 'lit-html/directives/class-map.js';
Expand Down

0 comments on commit 40428f6

Please sign in to comment.