compose: Don't select compose input field after focus.

Fixes #25950.

Focus area is mostly determined by finding the first
relevant field that is *empty*, and selecting empty
fields has no effect.

The only situation where the field might not be empty
is when the textarea already has text in it, since
that's the default option. We don't want to select
the composebox textarea because this can lead to
people losing their messages if they start typing
right away.
This commit is contained in:
evykassirer 2023-07-04 11:07:12 -04:00 committed by Tim Abbott
parent aa86533f22
commit 92e24a9727
1 changed files with 4 additions and 2 deletions

View File

@ -57,10 +57,12 @@ function get_focus_area(msg_type, opts) {
export const _get_focus_area = get_focus_area;
export function set_focus(msg_type, opts) {
// Called mainly when opening the compose box or switching the
// message type to set the focus in the first empty input in the
// compose box.
if (window.getSelection().toString() === "" || opts.trigger !== "message click") {
const focus_area = get_focus_area(msg_type, opts);
const $elt = $(focus_area);
$elt.trigger("focus").trigger("select");
$(focus_area).trigger("focus");
}
}