element icon indicating copy to clipboard operation
element copied to clipboard

[Bug Report] 当搜索栏只有一个form表单中只有一个input框时,使用键盘的enter事件会改变路由地址,会加上一个“问号”

Open tongmintsai opened this issue 6 years ago • 5 comments

Element UI version

2.13.2

OS/Browsers version

WIN10 / chrome浏览器 版本 80.0.3987.122(正式版本) (64 位)

Vue version

3.0.0-beta.14

Reproduction Link

https://codepen.io/pen/?&editable=true=https%3A%2F%2Felement.eleme.io%2F%3F

Steps to reproduce

https://element.eleme.cn/#/zh-CN/component/form 数字类型验证,在线运行,聚焦到input框后,直接使用键盘的enter即可复现,没有自定义enter事件,却触发了enter事件

What is Expected?

不触发默认的enter事件

What is actually happening?

触发了默认的enter事件

tongmintsai avatar May 25 '20 11:05 tongmintsai

W3C 标准中有如下规定:当一个 form 元素中只有一个输入框时,在该输入框中按下回车应提交该表单。 具体可以看https://element.eleme.cn/?#/zh-CN/component/form

FFFFof7 avatar Jun 01 '20 07:06 FFFFof7

如果想规避默认行为,可以另加一个输入框。

<el-form-item v-show="false">
  <el-input />
</el-form-item>

deepraining avatar Sep 15 '20 08:09 deepraining

如果有多个输入框,但是希望保留这个 onEnter 效果,应该怎么写

hbrls avatar Mar 26 '21 05:03 hbrls

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 16 '22 15:04 stale[bot]

参考:https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#implicit-submission

kpi311 avatar May 16 '25 02:05 kpi311