From b0b28c3bcfe5067f9eb2df67f386174ac49ccc6a Mon Sep 17 00:00:00 2001 From: Henriette Dinger Date: Fri, 27 Jul 2018 16:03:59 +0200 Subject: [PATCH] Correct focus handling --- app/assets/javascripts/forums.js | 5 ++--- app/views/messages/_form.html.erb | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/forums.js b/app/assets/javascripts/forums.js index 96ee527d2e..0f3e28497e 100644 --- a/app/assets/javascripts/forums.js +++ b/app/assets/javascripts/forums.js @@ -32,7 +32,7 @@ function quoteResult(result) { var reply = $("#reply"), subject = $("#reply_subject"), - content = $("#reply_content"); + focusElement = jQuery("#reply #message-form"); subject.val(result.subject); @@ -43,10 +43,9 @@ }); reply.slideDown(); - content.focus(); $('html, body').animate({ - scrollTop: content.offset().top + scrollTop: focusElement.offset().top }, 1000); } diff --git a/app/views/messages/_form.html.erb b/app/views/messages/_form.html.erb index bcdc76b571..3d29fcee25 100644 --- a/app/views/messages/_form.html.erb +++ b/app/views/messages/_form.html.erb @@ -29,7 +29,7 @@ See docs/COPYRIGHT.rdoc for more details. <%= error_messages_for 'message' %> <% replying ||= false %>
- <%= f.text_field :subject, required: true, container_class: '-wide' %> + <%= f.text_field :subject, required: true, container_class: '-wide', autofocus: true %>
<% unless replying %>