diff --git a/packages/svelte-ux/src/lib/components/TextField.svelte b/packages/svelte-ux/src/lib/components/TextField.svelte index 22578e0b5..f841b3b07 100644 --- a/packages/svelte-ux/src/lib/components/TextField.svelte +++ b/packages/svelte-ux/src/lib/components/TextField.svelte @@ -61,7 +61,13 @@ ? (node) => [autoFocus(node, typeof autofocus === 'object' ? autofocus : undefined)] : undefined; export let operators: { label: string; value: string }[] | undefined = undefined; - export let inputEl: HTMLInputElement | null = null; + export let inputEl: HTMLInputElement | HTMLTextAreaElement | null = null; + // this is a workaround because Input only accepts an HTMLInputElement, not a TextAreaElement + const inputHolder = { + set input(value: HTMLInputElement | null) { + inputEl = value; + }, + }; export let debounceChange: boolean | number = false; export let classes: { root?: string; @@ -327,6 +333,7 @@ {disabled} value={inputValue} {autocapitalize} + bind:this={inputEl} on:input={handleInput} on:focus on:blur @@ -366,7 +373,7 @@ {max} {step} {actions} - bind:inputEl + bind:inputEl={inputHolder.input} on:input={handleInput} on:focus on:blur diff --git a/packages/svelte-ux/src/routes/docs/components/TextField/+page.svelte b/packages/svelte-ux/src/routes/docs/components/TextField/+page.svelte index b42331701..7de62d0bb 100644 --- a/packages/svelte-ux/src/routes/docs/components/TextField/+page.svelte +++ b/packages/svelte-ux/src/routes/docs/components/TextField/+page.svelte @@ -20,6 +20,7 @@ import Preview from '$lib/components/Preview.svelte'; import Blockquote from '$docs/Blockquote.svelte'; + import Toggle from '$lib/components/Toggle.svelte'; const numberOperators = [ { label: '=', value: 'equal' }, @@ -40,6 +41,8 @@ let value = ''; let numberValue = 1; let multilineValue = 'one\ntwo\nthree'; + + let inputEl: HTMLInputElement | HTMLTextAreaElement | null = null;

Examples

@@ -225,6 +228,18 @@ /> +

bind:inputEl

+ + +
+ + + + + +
+
+ Type

Input types