feat(ComboBox): selectedIndex -> selectedId (#1016)

* feat(breaking): selectedIndex -> selectedId in ComboBox

* docs: update ComboBox
This commit is contained in:
Koichi Kiyokawa 2022-01-18 23:37:55 +09:00 committed by GitHub
commit cde8a79fa8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 91 additions and 102 deletions

View file

@ -1,12 +1,12 @@
<script>
import { ComboBox, Button } from "carbon-components-svelte";
let selectedIndex = 1;
let selectedId = "1";
</script>
<ComboBox
titleText="Contact"
placeholder="Select contact method"
bind:selectedIndex
bind:selectedId
items="{[
{ id: '0', text: 'Slack' },
{ id: '1', text: 'Email' },
@ -14,5 +14,7 @@
]}"
/>
<br />
<Button on:click="{() => (selectedIndex = -1)}">Set to -1 (unselected)</Button>
<Button on:click="{() => (selectedIndex = 2)}">Set to 2 (Fax)</Button>
<Button on:click="{() => (selectedId = undefined)}"
>Set to undefined (unselected)</Button
>
<Button on:click="{() => (selectedId = '2')}">Set to 2 (Fax)</Button>