New Issue page: pressing "Enter" focuses the "Description" field instead of submitting
Summary
On the New Issue page, pressing Enter in the Title field focuses the Description field instead of immediately creating a new issue.
Further details
This may not sound like a bug - in fact, it's kind of convenient! - but this is actually an unintended side effect of how the Markdown editor is built.
The Write and Preview tabs in the Description field are actually <button>s, and the browser's default behavior is to click the first button in the form when Enter is pressed (under the assumption that this is a "Submit" button).
Because of this, what actually happens when Enter is pressed on the New Issue page is that the Write tab is clicked, which focuses the Description field.
This isn't standard behavior - pressing Enter in an <input> element should submit the current form. This is reinforced by our Pajamas documentation:
When keyboard focus is inside an input field, pressing the Enter key should submit the form (provided there are no validation errors).
Note on usability
Since this "bug" is kind of convenient, some users may currently rely on this behavior. We shouldn't remove it without a viable alternative. We should resolve #225542 (closed) before we change this behavior, because right now this "bug" is the only convenient way to navigate the New Issue page by keyboard.
Steps to reproduce
- Navigate to the New Issues page (
/-/issues/new) - Type something in the Title field and press Enter
What is the current bug behavior?
The Description field is focused and the issue is not immediately submitted.
What is the expected correct behavior?
The issue is immediately submitted.
Output of checks
This bug happens on GitLab.com.
Possible fixes
Add type="button" to the Write and Preview <button>s.