feat(ComboBox): add a reference to the list HTML element, forward scroll event

This commit is contained in:
weaseldotro 2020-10-25 11:18:19 +02:00 committed by GitHub
commit 0b21a6d3f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -106,6 +106,12 @@
* @type {null | HTMLInputElement} [ref=null] * @type {null | HTMLInputElement} [ref=null]
*/ */
export let ref = null; export let ref = null;
/**
* Obtain a reference to the list HTML element
* @type {null | HTMLElement} [ref=null]
*/
export let listRef = null
/** /**
* @typedef {{ id: string; text: string; }} ComboBoxItem * @typedef {{ id: string; text: string; }} ComboBoxItem
@ -284,7 +290,7 @@
/> />
</ListBoxField> </ListBoxField>
{#if open} {#if open}
<ListBoxMenu aria-label="{ariaLabel}" id="{id}"> <ListBoxMenu aria-label="{ariaLabel}" id="{id}" on:scroll bind:ref={listRef}>
{#each filteredItems as item, i (item.id)} {#each filteredItems as item, i (item.id)}
<ListBoxMenuItem <ListBoxMenuItem
id="{item.id}" id="{item.id}"