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

Autocomplete: add change event #17913

Merged
merged 1 commit into from
Apr 10, 2020
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
1 change: 1 addition & 0 deletions examples/docs/en-US/input.md
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,7 @@ Attribute | Description | Type | Options | Default
| Event Name | Description | Parameters |
|----| ----| ----|
|select | triggers when a suggestion is clicked | suggestion being clicked |
| change | triggers when the icon inside Input value change | (value: string \| number) |

### Autocomplete Methods

Expand Down
1 change: 1 addition & 0 deletions examples/docs/es/input.md
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,7 @@ export default {
| Nombre | Descripción | Parametros |
| ------ | ----------------------------------------------- | ------------------------------------------ |
| select | se dispara cuando se hace clic a una sugerencia | sugerencia en la que se está haciendo clic |
| change | se activa cuando cambia el valor de entrada | (value: string \| number) |

### Autocomplete Metodo

Expand Down
1 change: 1 addition & 0 deletions examples/docs/fr-FR/input.md
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,7 @@ export default {
| Nom | Description | Paramètres |
|----| ----| ----|
| select | Se déclenche quand une suggestion est cliquée. | La suggestion sélectionnée. |
| change | Se déclenche quand la valeur change. | (value: string \ number) |

### Méthodes de l'autocomplétion

Expand Down
1 change: 1 addition & 0 deletions examples/docs/zh-CN/input.md
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,7 @@ export default {
| 事件名称 | 说明 | 回调参数 |
|---------|--------|---------|
| select | 点击选中建议项时触发 | 选中建议项 |
| change | 在 Input 值改变时触发 | (value: string \| number) |

### Autocomplete Methods
| 方法名 | 说明 | 参数 |
Expand Down
8 changes: 6 additions & 2 deletions packages/autocomplete/src/autocomplete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
<el-input
ref="input"
v-bind="[$props, $attrs]"
@input="handleChange"
@input="handleInput"
@change="handleChange"
@focus="handleFocus"
@blur="handleBlur"
@clear="handleClear"
Expand Down Expand Up @@ -186,7 +187,7 @@
}
});
},
handleChange(value) {
handleInput(value) {
this.$emit('input', value);
this.suggestionDisabled = false;
if (!this.triggerOnFocus && !value) {
Expand All @@ -196,6 +197,9 @@
}
this.debouncedGetData(value);
},
handleChange(event) {
this.$emit('change', event.target.value);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#19243

Emitted event from el-input contains the value of the input, not the event. This code throws an error because target is undefined.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in #19200

},
handleFocus(event) {
this.activated = true;
this.$emit('focus', event);
Expand Down