From 729612d2e62349589c638713cd69af7b05a59dc1 Mon Sep 17 00:00:00 2001 From: Thomas Wilburn Date: Mon, 12 May 2014 21:17:55 -0700 Subject: [PATCH] Focus default dialog if you click away from it. --- js/ui/dialog.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/js/ui/dialog.js b/js/ui/dialog.js index d96b209..44587e1 100644 --- a/js/ui/dialog.js +++ b/js/ui/dialog.js @@ -31,12 +31,6 @@ define([ buttons: buttons }); - modal.on("click", function(e) { - if (e.target != modal) return; - e.preventDefault(); - e.stopImmediatePropagation(); - }); - document.body.append(modal); setTimeout(function() { //trigger enter animations @@ -46,6 +40,13 @@ define([ var defaultButton = modal.find("button.default"); if (!defaultButton) defaultButton = modal.find("button"); defaultButton.focus(); + + modal.on("click", function(e) { + if (e.target != modal) return; + e.preventDefault(); + e.stopImmediatePropagation(); + defaultButton.focus(); + }); var onKeyDown = function(e) { e.stopPropagation();