Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/autocomplete/src/Autocomplete.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
</slot>
</Item>
{:else}
{#each matches as match, i}
{#each matchesToDisplay as match, i}
<Item
disabled={getOptionDisabled(match)}
selected={match === value}
Expand Down Expand Up @@ -193,6 +193,7 @@
});
return result;
};
export let maxOptionsToDisplay = 0;
export let menu$class = '';
export let menu$anchor = false;
export let menu$anchorCorner: ComponentProps<Menu>['anchorCorner'] =
Expand All @@ -205,6 +206,8 @@
let focused = false;
let listAccessor: SMUIListAccessor;
let matches: any[] = [];
$: matchesToDisplay =
maxOptionsToDisplay > 0 ? matches.slice(0, maxOptionsToDisplay) : matches;
let focusedIndex = -1;
let focusedItem: SMUIListItemAccessor | undefined = undefined;

Expand Down
10 changes: 10 additions & 0 deletions packages/site/src/routes/demo/autocomplete/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@

<pre class="demo-spaced">npm i -D @smui-extra/autocomplete</pre>

<h5>Performance</h5>

<p>
When dealing with long lists (&gt;50 elements), the creation of the DOM
elements inside the list starts to become a bottleneck. In this case, you
may want to use the <code>maxOptionsToDisplay</code> option. This option limits
the number of list items that can be rendered at a time. When set to 0 (default),
every item will be rendered.
</p>

<h5>Demos</h5>

<Demo component={Simple} file="autocomplete/_Simple.svelte" />
Expand Down