compose: Rename placeholder update function for clarity.

This commit is contained in:
Karl Stolley
2025-02-06 09:42:22 -06:00
committed by Tim Abbott
parent 81b6879464
commit cae48d3faa
8 changed files with 15 additions and 13 deletions

View File

@@ -193,7 +193,7 @@ export let complete_starting_tasks = (opts: ComposeActionsOpts): void => {
maybe_scroll_up_selected_message(opts);
compose_fade.start_compose(opts.message_type);
$(document).trigger(new $.Event("compose_started.zulip", opts));
compose_recipient.update_placeholder_text();
compose_recipient.update_compose_area_placeholder_text();
compose_recipient.update_narrow_to_recipient_visibility();
// We explicitly call this function here apart from compose_setup.js
// as this helps to show banner when responding in an interleaved view.

View File

@@ -175,7 +175,7 @@ function switch_message_type(message_type: MessageType): void {
private_message_recipient: compose_state.private_message_recipient(),
};
update_compose_for_message_type(opts);
update_placeholder_text();
update_compose_area_placeholder_text();
compose_ui.set_focus(opts);
}
@@ -348,7 +348,7 @@ export function initialize(): void {
$("#private_message_recipient").on("input", restore_placeholder_in_firefox_for_no_input);
}
export let update_placeholder_text = (): void => {
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.
if (!$textarea.is(":visible")) {
@@ -375,8 +375,10 @@ export let update_placeholder_text = (): void => {
compose_ui.autosize_textarea($textarea);
};
export function rewire_update_placeholder_text(value: typeof update_placeholder_text): void {
update_placeholder_text = value;
export function rewire_update_compose_area_placeholder_text(
value: typeof update_compose_area_placeholder_text,
): void {
update_compose_area_placeholder_text = value;
}
// This function addresses the issue of the placeholder not reappearing in Firefox

View File

@@ -582,7 +582,7 @@ export function initialize() {
});
$("textarea#compose-textarea").on("focus", () => {
compose_recipient.update_placeholder_text();
compose_recipient.update_compose_area_placeholder_text();
if (narrow_state.narrowed_by_reply()) {
compose_notifications.maybe_show_one_time_non_interleaved_view_messages_fading_banner();
} else {
@@ -604,11 +604,11 @@ export function initialize() {
});
$("input#stream_message_recipient_topic").on("focus", () => {
compose_recipient.update_placeholder_text();
compose_recipient.update_compose_area_placeholder_text();
});
$("input#stream_message_recipient_topic").on("input", () => {
compose_recipient.update_placeholder_text();
compose_recipient.update_compose_area_placeholder_text();
});
$("body").on("click", ".formatting_button", function (e) {

View File

@@ -1056,7 +1056,7 @@ export function dispatch_normal_event(event) {
// Update the status text in compose box placeholder when opened to self.
if (compose_pm_pill.get_user_ids().includes(event.user_id)) {
compose_recipient.update_placeholder_text();
compose_recipient.update_compose_area_placeholder_text();
}
}

View File

@@ -569,7 +569,7 @@ export function initialize_everything(state_data) {
compose_recipient.initialize();
compose_pm_pill.initialize({
on_pill_create_or_remove() {
compose_recipient.update_placeholder_text();
compose_recipient.update_compose_area_placeholder_text();
compose_recipient.check_posting_policy_for_compose_box();
},
});

View File

@@ -822,7 +822,7 @@ test_ui("on_events", ({override, override_rewire}) => {
(function test_undo_markdown_preview_clicked() {
fake_compose_box.show_message_preview();
override_rewire(compose_recipient, "update_placeholder_text", noop);
override_rewire(compose_recipient, "update_compose_area_placeholder_text", noop);
override(narrow_state, "narrowed_by_reply", () => true);
override(
compose_notifications,

View File

@@ -165,7 +165,7 @@ function initialize_pm_pill(mock_template) {
$("#private_message_recipient").before = noop;
compose_pm_pill.initialize({
on_pill_create_or_remove: compose_recipient.update_placeholder_text,
on_pill_create_or_remove: compose_recipient.update_compose_area_placeholder_text,
});
$("#zephyr-mirror-error").is = noop;

View File

@@ -1087,7 +1087,7 @@ test("initialize", ({override, override_rewire, mock_template}) => {
},
}));
compose_pm_pill.initialize({
on_pill_create_or_remove: compose_recipient.update_placeholder_text,
on_pill_create_or_remove: compose_recipient.update_compose_area_placeholder_text,
});
let expected_value;