From f94370962acd7a41330e627325de693f816ccd92 Mon Sep 17 00:00:00 2001 From: Marius Balteanu Date: Sun, 28 Apr 2024 06:53:52 +0000 Subject: [PATCH] Focus on the textarea after clicking the Edit Journal button (#40556). Patch by Yasu Saku (@skys). git-svn-id: https://svn.redmine.org/redmine/trunk@22791 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/views/journals/edit.js.erb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/views/journals/edit.js.erb b/app/views/journals/edit.js.erb index 96cf6b4f8..73631840f 100644 --- a/app/views/journals/edit.js.erb +++ b/app/views/journals/edit.js.erb @@ -6,3 +6,13 @@ if ($("form#journal-<%= @journal.id %>-form").length > 0) { } else { $("#journal-<%= @journal.id %>-notes").after('<%= escape_javascript(render :partial => 'notes_form') %>'); } + +// Focus on the textarea +(() => { + const textarea = $("#journal-<%= @journal.id %>-form .wiki-edit"); + if (textarea.length > 0) { + textarea.focus(); + const textareaLength = textarea.val().length; + textarea.get(0).setSelectionRange(textareaLength, textareaLength); + } +})(); -- 2.39.5