Capture Tabs and Enters when in the blocking MRs field to tokenize the input
What does this MR do and why?
For #508324 (closed)
Problem
When in the related/blocking MRs field for an MR, pressing Enter
or Tab
either submits the form or moves out of the field (respectively).
It's highly unlikely either behavior is the desired outcome for a user entering values in that field.
Changes
This MR captures the keypresses for either Enter
or Tab
and prevents their default behavior (submit & leave-the-field, respectively).
It also additionally triggers the onBlur
behavior to "tokenize" the input immediately (instead of requiring an additional space
input).
Notes
Note that because Paste was specifically mentioned in the issue, I've included multiple tests of a paste, then submit or Enter
. The submit button works as expected both in the before and after, since a blur occurs on the field first, which tokenizes the input. The Enter
input after the paste was broken before (which submitted the form without tokenizing the input), which dropped the value of the field entirely. That's been resolved regardless of pasting or not, since Enter
no longer submits the form.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
How to set up and validate locally
- Go to the MR creation (or edit) page
- Use the "Merge request dependencies" input:
- Direct typing, paste
- Press Enter, Tab