Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
compose: Fix placeholder disappearance bug.
ritwik-6920fef7576dab
diff --git a/web/src/compose_recipient.ts b/web/src/compose_recipient.tsindex e4e038a3be5..38ef7061f0f 100644--- a/web/src/compose_recipient.ts+++ b/web/src/compose_recipient.ts@@ -343,6 +343,8 @@ export function initialize(): void {update_on_recipient_change();compose_state.set_recipient_edited_manually(true);});++ $("#private_message_recipient").on("input", restore_placeholder_in_firefox_for_no_input);}export let update_placeholder_text = (): void => {@@ -375,3 +377,15 @@ export let update_placeholder_text = (): void => {export function rewire_update_placeholder_text(value: typeof update_placeholder_text): void {update_placeholder_text = value;}++// This function addresses the issue of the placeholder not reappearing in Firefox+// when the user types into an input field and then deletes the content.+// The problem arises due to the `contenteditable` attribute, which in some browsers+// (like Firefox) inserts a <br> tag when the input is emptied. This <br> tag prevents+// the placeholder from showing up again. The function checks if the input is empty+// and contains a <br> tag, then removes it to restore the placeholder functionality.+export function restore_placeholder_in_firefox_for_no_input(): void {+ if ($("#private_message_recipient").text().trim() === "") {+ $("#private_message_recipient").empty();+ }+}