mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-14 18:01:06 +00:00
breaking(text-input): use native bind:value
, dispatch instead of forward change
, input
events (#1065)
Use the native `bind:value` to fix two-way reactivity. As a result, "type" is read through `$$restProps` because it cannot be dynamic when using `bind:value`. Extend value type to include `null` for the "number" type. This is similar to how `NumberInput` works; `null` represents "no value."
This commit is contained in:
parent
30a5f2c201
commit
989e0f4c65
5 changed files with 92 additions and 72 deletions
|
@ -1,8 +1,17 @@
|
|||
<script lang="ts">
|
||||
import { TextInput, TextInputSkeleton } from "../types";
|
||||
|
||||
let value = null;
|
||||
</script>
|
||||
|
||||
<TextInput labelText="User name" placeholder="Enter user name..." />
|
||||
<TextInput
|
||||
type="number"
|
||||
labelText="User name"
|
||||
placeholder="Enter user name..."
|
||||
bind:value
|
||||
on:input="{(e) => console.log(e.detail)}"
|
||||
on:change="{(e) => (value = e.detail)}"
|
||||
/>
|
||||
|
||||
<TextInput
|
||||
labelText="User name"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue