Add option to not re-focus ComboBox when invoking clear() (#1000)

* feat(combo-box): add option to clear accessor to not re-focus input

Closes #994

* yarn build:lib

* test(combo-box): validate clear accessor params

* docs(combo-box): add clear without focus to "Clear selection" example
This commit is contained in:
Eric Liu 2022-01-12 16:12:43 -10:00 committed by GitHub
commit 37f19d2171
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 57 additions and 43 deletions

View file

@ -0,0 +1,20 @@
<script>
import { ComboBox, Button } from "carbon-components-svelte";
let ref;
</script>
<ComboBox
titleText="Contact"
placeholder="Select contact method"
selectedIndex="{1}"
bind:this="{ref}"
items="{[
{ id: '0', text: 'Slack' },
{ id: '1', text: 'Email' },
{ id: '2', text: 'Fax' },
]}"
/>
<br />
<Button on:click="{ref.clear}">Clear</Button>
<Button on:click="{() => ref.clear({ focus: false })}">Clear (no focus)</Button>