Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
stream_settings: Focus on an edit modal field when opened.
PieterCKbed2c6bf5727
diff --git a/web/src/stream_create.ts b/web/src/stream_create.tsindex 399800f06a5..29b1f3e9375 100644--- a/web/src/stream_create.ts+++ b/web/src/stream_create.ts@@ -668,13 +668,17 @@ export function set_up_handlers(): void {}export function initialize(): void {- $("#channels_overlay_container").on("click", "#archived_stream_rename", (e) => {- e.preventDefault();- e.stopPropagation();- const stream_id = Number.parseInt($(e.currentTarget).attr("data-stream-id")!, 10);+ $("#channels_overlay_container").on(+ "click",+ "#archived_stream_rename",+ function (this: HTMLElement, e) {+ e.preventDefault();+ e.stopPropagation();+ const stream_id = Number.parseInt($(e.currentTarget).attr("data-stream-id")!, 10);- stream_edit.open_stream_edit_modal(stream_id);- });+ stream_edit.open_stream_edit_modal(stream_id, $(this).attr("id")!);+ },+ );}export function set_channel_folder_dropdown_value(folder_id: number): void {diff --git a/web/src/stream_edit.ts b/web/src/stream_edit.tsindex 7bae282dca1..2e131d4b208 100644--- a/web/src/stream_edit.ts+++ b/web/src/stream_edit.ts@@ -56,6 +56,7 @@ import * as stream_ui_updates from "./stream_ui_updates.ts";import * as sub_store from "./sub_store.ts";import type {StreamSubscription} from "./sub_store.ts";import * as ui_report from "./ui_report.ts";+import {place_caret_at_end} from "./ui_util.ts";import {user_settings} from "./user_settings.ts";import * as util from "./util.ts";@@ -101,7 +102,7 @@ export function setup_subscriptions_tab_hash(tab_key_value: string): void {}}-export function open_stream_edit_modal(stream_id: number): void {+export function open_stream_edit_modal(stream_id: number, open_modal_button_id: string): void {const stream = sub_store.get(stream_id);assert(stream !== undefined);@@ -141,6 +142,21 @@ export function open_stream_edit_modal(stream_id: number): void {.addClass("save-button").attr("data-stream-id", stream_id);},+ on_shown() {+ let $input: JQuery<HTMLInputElement | HTMLTextAreaElement> | undefined;+ switch (open_modal_button_id) {+ case "archived_stream_rename":+ case "channel_title_open_channel_info_modal":+ $input = $("#change_stream_name");+ break;+ case "open_stream_info_modal":+ $input = $("#change_stream_description");+ break;+ }+ if ($input) {+ place_caret_at_end(util.the($input));+ }+ },update_submit_disabled_state_on_change: true,});}@@ -745,29 +761,37 @@ export function initialize(): void {e.preventDefault();e.stopPropagation();const stream_id = get_stream_id(this);- open_stream_edit_modal(stream_id);+ open_stream_edit_modal(stream_id, $(this).attr("id")!);},);- $("body").on("click", "#channel_title_open_channel_info_modal", (e) => {- e.preventDefault();- e.stopPropagation();- const $target = $(e.currentTarget).parents(".stream-title-buttons");- const stream_id = Number.parseInt($target.attr("data-stream-id")!, 10);+ $("body").on(+ "click",+ "#channel_title_open_channel_info_modal",+ function (this: HTMLElement, e) {+ e.preventDefault();+ e.stopPropagation();+ const $target = $(e.currentTarget).parents(".stream-title-buttons");+ const stream_id = Number.parseInt($target.attr("data-stream-id")!, 10);- dialog_widget.close();- open_stream_edit_modal(stream_id);- });+ dialog_widget.close();+ open_stream_edit_modal(stream_id, $(this).attr("id")!);+ },+ );- $("body").on("click", "#change_stream_info_modal #archived_stream_rename", (e) => {- e.preventDefault();- e.stopPropagation();+ $("body").on(+ "click",+ "#change_stream_info_modal #archived_stream_rename",+ function (this: HTMLElement, e) {+ e.preventDefault();+ e.stopPropagation();- const stream_id = Number.parseInt($(e.currentTarget).attr("data-stream-id")!, 10);+ const stream_id = Number.parseInt($(e.currentTarget).attr("data-stream-id")!, 10);- dialog_widget.close();- open_stream_edit_modal(stream_id);- });+ dialog_widget.close();+ open_stream_edit_modal(stream_id, $(this).attr("id")!);+ },+ );$("#channels_overlay_container").on("keydown", "#change_stream_description", (e) => {// Stream descriptions cannot be multiline, so disable enter key