Skip to content
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

Fixes #1794. Prevent form submission when pressing enter #2003

Merged
merged 1 commit into from
Jan 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions webcompat/static/js/lib/bugform.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ function BugForm() {
this.stepsToReproduceField = this.inputs.steps_reproduce.el;

this.init = function() {
// prevent accidental submission with the Enter key
// (for now, just the description input)
Mousetrap.bind("enter", function(e) {
if (e.target.className.indexOf("js-Desc") !== -1) {
e.preventDefault();
}
});

this.checkParams();
this.disableSubmits();
this.urlField.on("blur input", _.bind(this.checkURLValidity, this));
Expand Down
2 changes: 1 addition & 1 deletion webcompat/templates/home-page/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ <h3 class="wc-Title--s">Report Site Issue</h3>
{% endif %}
</div>
<span class="wc-Form-validation">
{{ form.description(class_='wc-Form-item required',
{{ form.description(class_='wc-Form-item required mousetrap js-Desc',
placeholder="e.g. The video doesn't play",
required=True, type='text', pattern='') }}
</span>
Expand Down