mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
compose: Correctly focus when replying to general chat.
This commit is contained in:
@@ -202,13 +202,18 @@ export function maybe_show_scrolling_formatting_buttons(container_selector: stri
|
||||
function get_focus_area(opts: ComposeTriggeredOptions): string {
|
||||
// Set focus to "Topic" when narrowed to a stream+topic
|
||||
// and "Start new conversation" button clicked.
|
||||
if (opts.message_type === "stream" && opts.stream_id && !opts.topic) {
|
||||
if (
|
||||
opts.message_type === "stream" &&
|
||||
opts.stream_id &&
|
||||
!opts.topic &&
|
||||
realm.realm_mandatory_topics
|
||||
) {
|
||||
return "input#stream_message_recipient_topic";
|
||||
} else if (
|
||||
(opts.message_type === "stream" && opts.stream_id !== undefined) ||
|
||||
(opts.message_type === "private" && opts.private_message_recipient)
|
||||
) {
|
||||
if (opts.trigger === "clear topic button") {
|
||||
if (opts.trigger === "clear topic button" || opts.trigger === "compose_hotkey") {
|
||||
return "input#stream_message_recipient_topic";
|
||||
}
|
||||
return "textarea#compose-textarea";
|
||||
|
||||
@@ -1280,7 +1280,7 @@ run_test("right-to-left", () => {
|
||||
});
|
||||
|
||||
const get_focus_area = compose_ui._get_focus_area;
|
||||
run_test("get_focus_area", () => {
|
||||
run_test("get_focus_area", ({override}) => {
|
||||
assert.equal(get_focus_area({message_type: "private"}), "#private_message_recipient");
|
||||
assert.equal(
|
||||
get_focus_area({
|
||||
@@ -1293,10 +1293,16 @@ run_test("get_focus_area", () => {
|
||||
get_focus_area({message_type: "stream"}),
|
||||
"#compose_select_recipient_widget_wrapper",
|
||||
);
|
||||
override(realm, "realm_mandatory_topics", true);
|
||||
assert.equal(
|
||||
get_focus_area({message_type: "stream", stream_name: "fun", stream_id: 4}),
|
||||
"input#stream_message_recipient_topic",
|
||||
);
|
||||
override(realm, "realm_mandatory_topics", false);
|
||||
assert.equal(
|
||||
get_focus_area({message_type: "stream", stream_name: "fun", stream_id: 4}),
|
||||
"textarea#compose-textarea",
|
||||
);
|
||||
assert.equal(
|
||||
get_focus_area({message_type: "stream", stream_name: "fun", stream_id: 4, topic: "more"}),
|
||||
"textarea#compose-textarea",
|
||||
|
||||
Reference in New Issue
Block a user