Clear ComboBox Programaticaly (#804)

* Added clear function

* Dispatching clear event

* Exporting function clear

* Added example
This commit is contained in:
Rafael Dessotti 2021-09-06 13:47:48 -03:00 committed by GitHub
commit dfc00f6668
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 7 deletions

View file

@ -1,6 +1,9 @@
<script>
import { ComboBox } from "carbon-components-svelte";
import { Button } from "carbon-components-svelte";
import Preview from "../../components/Preview.svelte";
let comboboxComponent
</script>
### Default
@ -22,6 +25,17 @@ items={[
{id: "2", text: "Fax"}
]} />
### Clear selection
<ComboBox titleText="Contact" placeholder="Select contact method"
bind:this={comboboxComponent}
items={[
{id: "0", text: "Slack"},
{id: "1", text: "Email"},
{id: "2", text: "Fax"}
]} />
<br>
<Button on:click={comboboxComponent.clear}>Clear</Button>
### Multiple combo boxes
<FileSource src="/framed/ComboBox/MultipleComboBox" />