From b5b4a8ac5d49dbb2d78631665817d5b2abc35512 Mon Sep 17 00:00:00 2001 From: TAKAHASHI Shuuji Date: Mon, 9 Jan 2023 04:22:45 +0900 Subject: [PATCH] Move initial cursor place to the end for @mention reply (#375) --- activities/views/compose.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/activities/views/compose.py b/activities/views/compose.py index eb27b18..827b105 100644 --- a/activities/views/compose.py +++ b/activities/views/compose.py @@ -60,6 +60,11 @@ class Compose(FormView): self.fields["text"].widget.attrs[ "_" ] = f""" + init + -- Move cursor to the end of existing text + set my.selectionStart to my.value.length + end + on load or input -- Unicode-aware counting to match Python set characters to Array.from(my.value.trim()).length