Skip to content

Commit

Permalink
compose: Remove the message_too_long banner.
Browse files Browse the repository at this point in the history
Since the banner only repeated what the disabled Send button's and the
limit indicator's tooltips already said, it was redundant and has been
removed.
  • Loading branch information
N-Shar-ma authored and timabbott committed Apr 30, 2024
1 parent bfbf4f6 commit b36cdfd
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 32 deletions.
1 change: 0 additions & 1 deletion web/src/compose_banner.ts
Expand Up @@ -52,7 +52,6 @@ export const CLASSNAMES = {
invalid_recipient: "invalid_recipient",
invalid_recipients: "invalid_recipients",
deactivated_user: "deactivated_user",
message_too_long: "message_too_long",
topic_missing: "topic_missing",
zephyr_not_running: "zephyr_not_running",
generic_compose_error: "generic_compose_error",
Expand Down
13 changes: 0 additions & 13 deletions web/src/compose_validate.ts
Expand Up @@ -703,17 +703,6 @@ export function check_overflow_text(): number {
remaining_characters,
}),
);
compose_banner.show_error_message(
$t(
{
defaultMessage:
"Message length shouldn't be greater than {max_length} characters.",
},
{max_length},
),
compose_banner.CLASSNAMES.message_too_long,
$("#compose_banners"),
);
set_message_too_long(true);
} else if (remaining_characters <= 900) {
$indicator.removeClass("over_limit");
Expand All @@ -724,13 +713,11 @@ export function check_overflow_text(): number {
}),
);
set_message_too_long(false);
$(`#compose_banners .${CSS.escape(compose_banner.CLASSNAMES.message_too_long)}`).remove();
} else {
$indicator.text("");
$("textarea#compose-textarea").removeClass("over_limit");

set_message_too_long(false);
$(`#compose_banners .${CSS.escape(compose_banner.CLASSNAMES.message_too_long)}`).remove();
}

return text.length;
Expand Down
18 changes: 0 additions & 18 deletions web/tests/compose_validate.test.js
Expand Up @@ -520,23 +520,10 @@ test_ui("test_validate_stream_message_post_policy_full_members_only", ({mock_tem
});

test_ui("test_check_overflow_text", ({mock_template}) => {
mock_banners();
realm.max_message_length = 10000;

const $textarea = $("textarea#compose-textarea");
const $indicator = $("#compose-limit-indicator");
let banner_rendered = false;
mock_template("compose_banner/compose_banner.hbs", false, (data) => {
assert.equal(data.classname, compose_banner.CLASSNAMES.message_too_long);
assert.equal(
data.banner_text,
$t({
defaultMessage: "Message length shouldn't be greater than 10000 characters.",
}),
);
banner_rendered = true;
return "<banner-stub>";
});

// Indicator should show red colored text
let limit_indicator_html;
Expand All @@ -548,27 +535,22 @@ test_ui("test_check_overflow_text", ({mock_template}) => {
assert.ok($indicator.hasClass("over_limit"));
assert.equal(limit_indicator_html, "-1\n");
assert.ok($textarea.hasClass("over_limit"));
assert.ok(banner_rendered);
assert.ok($(".message-send-controls").hasClass("disabled-message-send-controls"));

// Indicator should show orange colored text
banner_rendered = false;
$textarea.val("a".repeat(9100));
compose_validate.check_overflow_text();
assert.ok(!$indicator.hasClass("over_limit"));
assert.equal(limit_indicator_html, "900\n");
assert.ok(!$textarea.hasClass("over_limit"));
assert.ok(!$(".message-send-controls").hasClass("disabled-message-send-controls"));
assert.ok(!banner_rendered);

// Indicator must be empty
banner_rendered = false;
$textarea.val("a".repeat(9100 - 1));
compose_validate.check_overflow_text();
assert.ok(!$indicator.hasClass("over_limit"));
assert.equal($indicator.text(), "");
assert.ok(!$textarea.hasClass("over_limit"));
assert.ok(!banner_rendered);
});

test_ui("needs_subscribe_warning", () => {
Expand Down

0 comments on commit b36cdfd

Please sign in to comment.