From 7e75cd0508c6ebe32f5fee4ce3fd23b2be6d40a1 Mon Sep 17 00:00:00 2001 From: Jonathan la Cour Date: Tue, 6 Oct 2015 15:41:14 -0600 Subject: [PATCH] Improved input focusing when there are multiple fields --- gridforms/gridforms.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gridforms/gridforms.js b/gridforms/gridforms.js index 87f8870..fb9afeb 100644 --- a/gridforms/gridforms.js +++ b/gridforms/gridforms.js @@ -42,8 +42,12 @@ $(function() { }, events: function() { var that = this; - that.el.fieldsContainers.click(function() { - $(this).find('input[type="text"], textarea, select').focus(); + that.el.fieldsContainers.click(function(event) { + var focusableFields = that.el.focusableFields.selector; + + if (!$(event.target).is(focusableFields)) { + $(this).find('input[type="text"], textarea, select').first().focus(); + } }); that.el.focusableFields.focus(function() { that.focusField($(this));