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: Update compose placeholder text if recipients are changed.

Vinit Singhd43b1765d557
diff --git a/frontend_tests/node_tests/compose.js b/frontend_tests/node_tests/compose.js
index 6c2cf3a5116..b3e6f5b6db0 100644
--- a/frontend_tests/node_tests/compose.js
+++ b/frontend_tests/node_tests/compose.js
@@ -11,6 +11,9 @@ const noop = function () {};
set_global("$", global.make_zjquery());
set_global("DOMParser", new JSDOM().window.DOMParser);
+set_global("compose_actions", {
+ update_placeholder_text: noop,
+});
const LazySet = zrequire("lazy_set").LazySet;
diff --git a/frontend_tests/node_tests/compose_actions.js b/frontend_tests/node_tests/compose_actions.js
index 3ec72bac459..51469393d27 100644
--- a/frontend_tests/node_tests/compose_actions.js
+++ b/frontend_tests/node_tests/compose_actions.js
@@ -29,6 +29,8 @@ zrequire("stream_data");
set_global("document", "document-stub");
+compose_actions.update_placeholder_text = noop;
+
const start = compose_actions.start;
const cancel = compose_actions.cancel;
const get_focus_area = compose_actions._get_focus_area;
diff --git a/frontend_tests/node_tests/compose_pm_pill.js b/frontend_tests/node_tests/compose_pm_pill.js
index 02437be60d3..b60e75261b8 100644
--- a/frontend_tests/node_tests/compose_pm_pill.js
+++ b/frontend_tests/node_tests/compose_pm_pill.js
@@ -119,6 +119,10 @@ run_test("pills", () => {
input_pill.create = input_pill_stub;
+ // We stub the return value of input_pill.create(), manually add widget functions to it.
+ pills.onPillCreate = () => {};
+ pills.onPillRemove = () => {};
+
compose_pm_pill.initialize();
assert(compose_pm_pill.widget);
diff --git a/static/js/compose_actions.js b/static/js/compose_actions.js
index 76e03c240ab..d7d5d1c33a8 100644
--- a/static/js/compose_actions.js
+++ b/static/js/compose_actions.js
@@ -174,6 +174,11 @@ function same_recipient_as_before(msg_type, opts) {
}
exports.update_placeholder_text = function () {
+ // Change compose placeholder text only if compose box is open.
+ if (!$("#compose-textarea").is(":visible")) {
+ return;
+ }
+
const opts = {
message_type: compose_state.get_message_type(),
stream: $("#stream_message_recipient_stream").val(),
diff --git a/static/js/compose_pm_pill.js b/static/js/compose_pm_pill.js
index c5352d06063..3ac6143c9d8 100644
--- a/static/js/compose_pm_pill.js
+++ b/static/js/compose_pm_pill.js
@@ -10,6 +10,8 @@ exports.initialize_pill = function () {
container,
create_item_from_text: user_pill.create_item_from_email,
get_text_from_item: user_pill.get_email_from_item,
+ onPillCreate: input_pill.onPillCreate,
+ onPillRemove: input_pill.onPillRemove,
});
return pill;
@@ -17,6 +19,14 @@ exports.initialize_pill = function () {
exports.initialize = function () {
exports.widget = exports.initialize_pill();
+
+ exports.widget.onPillCreate(() => {
+ compose_actions.update_placeholder_text();
+ });
+
+ exports.widget.onPillRemove(() => {
+ compose_actions.update_placeholder_text();
+ });
};
exports.clear = function () {