# 使用“Enter”提交偏好设置表单会原生提交表单

**URL:** <https://meta.discourse.org/t/submitting-preferences-form-with-enter-submits-the-form-natively/390515>\
**Category:** Bug\
**Created:** [2025年十二月5日 14:22 UTC](https://meta.discourse.org/t/submitting-preferences-form-with-enter-submits-the-form-natively/390515 "2025-12-05T14:22:00Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [2025年十二月8日 01:12 UTC](https://meta.discourse.org/t/submitting-preferences-form-with-enter-submits-the-form-natively/390515/8 "2025-12-08T01:12:52Z")

</div>

在干净的 `dv` 环境中 100% 可重现。

在最新版 Chrome 上：

`dv new enter-submit`  
`http://enter-submit.localhost/session/user1/become`  
访问  
`http://enter-submit.localhost/u/user1/preferences/account`  
更改名称  
点击回车键

页面重新加载。

对于像这样的情况，@martin / @j.jaffeux 在 `/frontend/discourse/app/controllers/preferences.js` 中感觉如何：

```plaintext
      
    @action
    preventSubmit(event) {
       event?.preventDefault();
    }
    <form class="form-vertical" {{on "submit" this.preventSubmit}}>
       {{outlet}}
     </section>

```

在这个非常特殊的情况下，我们有一个实际上不是表单的表单，这有点奇怪。

---

_[View the full topic](https://meta.discourse.org/t/submitting-preferences-form-with-enter-submits-the-form-natively/390515)._
