Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(components): [autocomplete] expose blur event #8364

Merged
merged 2 commits into from Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 8 additions & 12 deletions docs/en-US/component/autocomplete.md
Expand Up @@ -60,18 +60,13 @@ autocomplete/remote-search

## Autocomplete Slots

| Name | Description |
| ------- | ------------------------------- |
| prefix | content as Input prefix |
| suffix | content as Input suffix |
| prepend | content to prepend before Input |
| append | content to append after Input |

## Autocomplete Scoped Slot

| Name | Description |
| ---- | --------------------------------------------------------------------- |
| — | Custom content for input suggestions. The scope parameter is { item } |
| Name | Description |
| ------- | --------------------------------------------------------------------- |
| — | Custom content for input suggestions. The scope parameter is { item } |
| prefix | content as Input prefix |
| suffix | content as Input suffix |
| prepend | content to prepend before Input |
| append | content to append after Input |

## Autocomplete Events

Expand All @@ -85,3 +80,4 @@ autocomplete/remote-search
| Method | Description | Parameters |
| ------ | ----------------------- | ---------- |
| focus | focus the input element | — |
| blur | blur the input element | — |
6 changes: 6 additions & 0 deletions packages/components/autocomplete/src/autocomplete.vue
Expand Up @@ -292,6 +292,10 @@ const focus = () => {
inputRef.value?.focus()
}

const blur = () => {
inputRef.value?.blur()
}

const handleSelect = async (item: any) => {
emit(INPUT_EVENT, item[props.valueKey])
emit(UPDATE_MODEL_EVENT, item[props.valueKey])
Expand Down Expand Up @@ -369,6 +373,8 @@ defineExpose({
handleKeyEnter,
/** @description focus the input element */
focus,
/** @description blur the input element */
blur,
/** @description close suggestion */
close,
/** @description highlight an item in a suggestion */
Expand Down