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

SectorNordAG: Pressing 'Enter' key inside of <input> triggers wrong event in AgentTicketNote. #554

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
13 changes: 12 additions & 1 deletion var/httpd/htdocs/js/Core.Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,16 @@ Core.Form = (function (TargetNS) {
$("form input, select, textarea").off('change', FormModified);
}

/**
* This makes all forms submittable by using Enter inside inputs.
*/
$('body').on('keydown', 'input', function (Event) {
if (Event.keyCode == 13 && $(this).closest('form').find(':submit').length > 0) {
Event.preventDefault();
$(this.form).find(':submit').last().click();
}
});

/**
* This makes all forms submittable by using Ctrl+Enter inside textareas.
* On macOS you can use Command+Enter instead.
Expand All @@ -302,7 +312,8 @@ Core.Form = (function (TargetNS) {
if ((Event.ctrlKey || Event.metaKey) && Event.keyCode == 13) {
// We need to click() instead of submit(), since click() has
// a few useful event handlers tied to it, like validation.
$(this.form).find(':submit').first().click();
Event.preventDefault();
$(this.form).find(':submit').last().click();
}
});

Expand Down