Skip to content

Commit

Permalink
Autocomplete: add change event (ElemeFE#17913)
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz authored and hzsrc committed Feb 2, 2023
1 parent 5000342 commit 116464f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions examples/docs/en-US/input.md
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,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 @@ -674,6 +674,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 @@ -660,6 +660,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 @@ -769,6 +769,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);
},
handleFocus(event) {
this.activated = true;
this.$emit('focus', event);
Expand Down

0 comments on commit 116464f

Please sign in to comment.