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_banner: Remove focus triggers & rerenders from DM error banners.

Aman Agrawal3104afcfaf57
diff --git a/web/src/compose_banner.ts b/web/src/compose_banner.ts
index 3713a9b661d..d7890b428ff 100644
--- a/web/src/compose_banner.ts
+++ b/web/src/compose_banner.ts
@@ -208,8 +208,11 @@ export function show_error_message(
}
export function cannot_send_direct_message_error(error_message: string): void {
- // Remove any existing banners with this warning.
- $(`#compose_banners .${CSS.escape(CLASSNAMES.cannot_send_direct_message)}`).remove();
+ // If a banner with this classname already exists, avoid removing
+ // and re-creating it.
+ if ($(`#compose_banners .${CSS.escape(CLASSNAMES.cannot_send_direct_message)}`).length > 0) {
+ return;
+ }
const new_row_html = render_cannot_send_direct_message_error({
banner_type: ERROR,
@@ -218,8 +221,6 @@ export function cannot_send_direct_message_error(error_message: string): void {
});
append_compose_banner_to_banner_list($(new_row_html), $("#compose_banners"));
hide_compose_spinner();
-
- $("#private_message_recipient").trigger("focus").trigger("select");
}
export function topic_missing_error(empty_string_topic_display_name: string): void {
diff --git a/web/src/compose_validate.ts b/web/src/compose_validate.ts
index 17fa9b3545a..77d679756a4 100644
--- a/web/src/compose_validate.ts
+++ b/web/src/compose_validate.ts
@@ -1030,7 +1030,6 @@ export function validate_private_message(show_banner = true): boolean {
error_message,
compose_banner.CLASSNAMES.deactivated_user,
$banner_container,
- $("#private_message_recipient"),
);
if (is_validating_compose_box) {