Skip to content
Snippets Groups Projects
Commit 2db02858 authored by Shane Tomlinson's avatar Shane Tomlinson
Browse files

Fix submit occuring when selecting an email address in Firefox from the autocomplete list.

issue #1780
parent a976e5a3
No related branches found
No related tags found
No related merge requests found
......@@ -15,7 +15,7 @@ BrowserID.Modules.PageModule = (function() {
cancelEvent = helpers.cancelEvent,
mediator = bid.Mediator;
function onKeypress(event) {
function onKeyup(event) {
if (event.which === 13) {
// IE8 does not trigger the submit event when hitting enter. Submit the
// form if the key press was an enter and prevent the default action so
......@@ -69,7 +69,7 @@ BrowserID.Modules.PageModule = (function() {
self.options = options || {};
self.bind("form", "submit", cancelEvent(onSubmit));
self.bind("input", "keypress", onKeypress);
self.bind("input", "keyup", onKeyup);
},
stop: function() {
......
......@@ -200,7 +200,7 @@
equal(submitCalled, true, "submit permitted to complete");
});
test("form is submitted once 'enter keypress' event", function() {
test("form is submitted on 'enter keyup' event", function() {
createController();
controller.renderDialog("test_template_with_input", {
title: "Test title",
......@@ -216,14 +216,15 @@
};
// synthesize the entire series of key* events so we replicate the behavior
// of keyboard interaction.
// of keyboard interaction. The order of events is keydown, keypress,
// keyup (http://unixpapa.com/js/key.html).
var e = jQuery.Event("keydown", { keyCode: 13, which: 13 });
$("#templateInput").trigger(e);
var e = jQuery.Event("keyup", { keyCode: 13, which: 13 });
var e = jQuery.Event("keypress", { keyCode: 13, which: 13 });
$("#templateInput").trigger(e);
var e = jQuery.Event("keypress", { keyCode: 13, which: 13 });
var e = jQuery.Event("keyup", { keyCode: 13, which: 13 });
$("#templateInput").trigger(e);
equal(submitCalled, 1, "submit called a single time");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment