fix(input): add keydown event listener for textarea (#1723)

This commit is contained in:
inottn 2021-03-31 16:24:42 +08:00 committed by GitHub
parent c3d1d14bdd
commit a02737a78a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 0 deletions

View File

@ -445,6 +445,30 @@ describe('Input.vue', () => {
expect(handleKeyup).toBeCalledTimes(1)
})
describe('Textarea Events', () => {
test('event:keydown', async () => {
const handleKeydown = jest.fn()
const wrapper = _mount({
template: `<el-input
type="textarea"
:model-value="val"
@keydown="handleKeydown"
/>`,
setup() {
const val = ref('')
return {
val,
handleKeydown,
}
},
})
await wrapper.find('textarea').trigger('keydown')
expect(handleKeydown).toBeCalledTimes(1)
})
})
// TODO: validateEvent & input containes select cases should be added after the rest components finished
// ...

View File

@ -98,6 +98,7 @@
@focus="handleFocus"
@blur="handleBlur"
@change="handleChange"
@keydown="handleKeydown"
>
</textarea>
<span v-if="isWordLimitVisible && type === 'textarea'" class="el-input__count">{{ textLength }}/{{ upperLimit }}</span>