inputElementID param
This commit is contained in:
parent
1386b80d0c
commit
4d79589903
@ -1,6 +1,11 @@
|
|||||||
<script>
|
<script>
|
||||||
import { createEventDispatcher, onMount, tick } from "svelte";
|
import { createEventDispatcher, onMount, tick } from "svelte";
|
||||||
|
|
||||||
|
// Generate a default unique ID
|
||||||
|
function generateDefaultID() {
|
||||||
|
return "virtual-select-" + Math.random().toString(36).slice(2);
|
||||||
|
}
|
||||||
|
|
||||||
// Props
|
// Props
|
||||||
export let options = [];
|
export let options = [];
|
||||||
export let selected = null;
|
export let selected = null;
|
||||||
@ -11,6 +16,7 @@
|
|||||||
export let clearAriaLabel = "Clear selection";
|
export let clearAriaLabel = "Clear selection";
|
||||||
export let filterFn = null; // Custom filter function
|
export let filterFn = null; // Custom filter function
|
||||||
export let autofocus = false; // Autofocus input
|
export let autofocus = false; // Autofocus input
|
||||||
|
export let inputElementID = generateDefaultID(); // Input element ID
|
||||||
|
|
||||||
// Internal state
|
// Internal state
|
||||||
let searchTerm = "";
|
let searchTerm = "";
|
||||||
@ -191,6 +197,7 @@
|
|||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
|
id={inputElementID}
|
||||||
bind:value={searchTerm}
|
bind:value={searchTerm}
|
||||||
bind:this={inputElement}
|
bind:this={inputElement}
|
||||||
placeholder={getDisplayText()}
|
placeholder={getDisplayText()}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user