Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

compose: Avoid multiple 'input' handlers on topic box.

Karl Stolley415f7610c968
diff --git a/web/src/compose_recipient.ts b/web/src/compose_recipient.ts
index b329628ca8d..7711364c534 100644
--- a/web/src/compose_recipient.ts
+++ b/web/src/compose_recipient.ts
@@ -447,9 +447,6 @@ export function update_topic_displayed_text(topic_name = "", has_topic_focus = f
// Otherwise, we have some adjustments to make to display:
// * a placeholder with the default topic name stylized
// * the empty string topic stylized
- function update_placeholder_visibility(): void {
- $topic_not_mandatory_placeholder.toggleClass("visible", $input.val() === "");
- }
const is_empty_string_topic = compose_state.topic() === "";
if (
@@ -461,10 +458,16 @@ export function update_topic_displayed_text(topic_name = "", has_topic_focus = f
} else {
$topic_not_mandatory_placeholder.show();
update_placeholder_visibility();
- $input.on("input", update_placeholder_visibility);
}
}
+export function update_placeholder_visibility(): void {
+ const $input = $("input#stream_message_recipient_topic");
+ const $topic_not_mandatory_placeholder = $("#topic-not-mandatory-placeholder");
+
+ $topic_not_mandatory_placeholder.toggleClass("visible", $input.val() === "");
+}
+
export let update_compose_area_placeholder_text = (): void => {
const $textarea: JQuery<HTMLTextAreaElement> = $("textarea#compose-textarea");
// Change compose placeholder text only if compose box is open.
diff --git a/web/src/compose_setup.js b/web/src/compose_setup.js
index 9c1517cb7ea..e111222d57b 100644
--- a/web/src/compose_setup.js
+++ b/web/src/compose_setup.js
@@ -616,6 +616,7 @@ export function initialize() {
});
$("input#stream_message_recipient_topic").on("input", () => {
+ compose_recipient.update_placeholder_visibility();
compose_recipient.update_compose_area_placeholder_text();
});