From 7544afa9b274f68742bf3a514a60c71e58f80969 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 1 Dec 2016 14:56:39 +0100 Subject: [PATCH] Bug 17566: [Follow-up] Initial focus on first select or input Content-Type: text/plain; charset=utf-8 Previous patch just set the focus to the first input, because the focus on the first select does not show up in some browsers (incl FF). Joubu complained about that, which is not unreasonable :) This patch puts the focus on the first subfield (under conditions described earlier). We do not solve all browser problems here, but it still is an improvement compared to the original focus. Signed-off-by: Marcel de Rooy --- .../intranet-tmpl/prog/en/modules/cataloguing/additem.tt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt index 1b90ee9..0df5302 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt @@ -83,11 +83,17 @@ $(document).ready(function(){ multiCopyControl.toggle(); }); [% IF last_action == "additem" || last_action == "saveitem" || last_action == "delitem" %] + // Focus on the top search box $("input:text:visible:first").focus(); [% ELSE %] - $("fieldset.rows input:visible:first").focus(); - // FIXME: The first input gets focus. Note that focus on the first - // select does not show properly. + // Focus on first select or input + var firstsubfield = $("fieldset.rows div.subfield_line")[0]; + if( $(firstsubfield).find("select").length > 0 ) { + $("fieldset.rows select:first").focus(); + // TODO: This focus does not show up in all browsers (incl FF). + } else { + $("fieldset.rows input:visible:first").focus(); + } [% END %] }); -- 2.1.4