Project

General

Profile

Actions

Feature #40556

closed

Focus on the textarea after clicking the Edit Journal button

Added by Yasu Saku 8 months ago. Updated 8 months ago.

Status:
Closed
Priority:
Normal
Category:
Issues
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed

Description

I suggest adding the feature to focus on the textarea after clicking on the Edit Journal button.

Here is a simple patch as follows.

diff --git a/app/views/journals/edit.js.erb b/app/views/journals/edit.js.erb
index 96cf6b4f8..49fe4bec0 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);
+  }
+})();

Actions

Also available in: Atom PDF