Skip to content

a-input组件type为textarea时pressEnter事件会触发2次 #2590

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

Closed
1 task
Aiwass-wj opened this issue Jul 21, 2020 · 2 comments
Closed
1 task

a-input组件type为textarea时pressEnter事件会触发2次 #2590

Aiwass-wj opened this issue Jul 21, 2020 · 2 comments
Labels

Comments

@Aiwass-wj
Copy link

Aiwass-wj commented Jul 21, 2020

  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

1.6.1

Environment

UA:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36
Vue版本:2.6.10

Reproduction link

Edit on CodeSandbox

Steps to reproduce

在type为textarea的a-input组件中按下一次回车按键

What is expected?

pressEnter事件会只触发1次

What is actually happening?

pressEnter事件会触发了2次

@xrkffgg xrkffgg added the bug label Jul 22, 2020
@labike
Copy link

labike commented Jul 22, 2020

type="textarea"时, ant design vue内部是用将包裹了一层, 所以回车触发的事件应该是

<textarea /> --> pressEnter
<input /> --> pressEnter
<input /> --> keyDown
<textarea /> ---> keyDown
<Textarea />里是这样的 ``` handleKeyDown(e) { if (e.keyCode === 13) { this.$emit('pressEnter', e); } this.$emit('keydown', e); }, ``` 同时内部在渲染时做了判断 ``` if (this.$props.type === 'textarea') { const textareaProps = { props: this.$props, attrs: this.$attrs, on: { ...getListeners(this), input: this.handleChange, keydown: this.handleKeyDown, change: noop, }, }; return <TextArea {...textareaProps} ref="input" />; } ``` 例外官网文档里也介绍了用`Input.TextArea`代替`type="textarea"` 注: 可以在vuedevtools调试看一下

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants