Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
compose: Improve tooltip on compose box "x" button.
Yogeshb8a760b14e57
diff --git a/static/js/compose.js b/static/js/compose.jsindex f6e553598d2..97fee775366 100644--- a/static/js/compose.js+++ b/static/js/compose.js@@ -412,7 +412,14 @@ export function initialize() {$("#compose-textarea").on("input propertychange", () => {compose_validate.warn_if_topic_resolved(false);- compose_validate.check_overflow_text();+ const compose_text_length = compose_validate.check_overflow_text();+ // Change compose close button tooltip as per condition.+ // We save compose text in draft only if its length is > 2.+ if (compose_text_length > 2) {+ $("#compose_close").attr("data-tooltip-template-id", "compose_close_and_save_tooltip");+ } else {+ $("#compose_close").attr("data-tooltip-template-id", "compose_close_tooltip");+ }});$("#compose form").on("submit", (e) => {diff --git a/static/js/compose_validate.js b/static/js/compose_validate.jsindex c3c92ef66b6..887d7615592 100644--- a/static/js/compose_validate.js+++ b/static/js/compose_validate.js@@ -581,6 +581,8 @@ export function check_overflow_text() {$("#compose-send-status").stop(true).fadeOut();}}++ return text.length;}export function warn_for_text_overflow_when_tries_to_send() {diff --git a/static/templates/compose.hbs b/static/templates/compose.hbsindex 4fc139ee1f6..3b83a659303 100644--- a/static/templates/compose.hbs+++ b/static/templates/compose.hbs@@ -66,6 +66,7 @@<button type="button" class="collapse_composebox_button fa fa-chevron-down" aria-label="{{t 'Collapse compose' }}" data-tippy-content="{{t 'Collapse compose' }}"></button><button type="button" class="close fa fa-times" id='compose_close' data-tooltip-template-id="compose_close_tooltip"></button><template id="compose_close_tooltip">{{t 'Cancel compose' }} <span class="hotkey-hint">(Esc)</span></template>+ <template id="compose_close_and_save_tooltip">{{t 'Cancel compose and save draft' }} <span class="hotkey-hint">(Esc)</span></template></div><div id="stream-message" class="order-1"><div class="stream-selection-header-colorblock message_header_stream left_part" tab-index="-1"></div>diff --git a/static/templates/keyboard_shortcuts.hbs b/static/templates/keyboard_shortcuts.hbsindex 32cfe2bfc74..1c12822e75b 100644--- a/static/templates/keyboard_shortcuts.hbs+++ b/static/templates/keyboard_shortcuts.hbs@@ -21,7 +21,7 @@<td><span class="hotkey"><kbd>X</kbd></span></td></tr><tr>- <td class="definition">{{t 'Cancel compose' }}</td>+ <td class="definition">{{t 'Cancel compose and save draft' }}</td><td><span class="hotkey"><kbd>Esc</kbd> or <kbd>Ctrl</kbd> + <kbd>[</kbd></span></td></tr><tr>@@ -143,7 +143,7 @@<td><span class="hotkey"><kbd>Shift</kbd> + <kbd>Enter</kbd></span></td></tr><tr>- <td class="definition">{{t 'Cancel compose' }}</td>+ <td class="definition">{{t 'Cancel compose and save draft' }}</td><td><span class="hotkey"><kbd>Esc</kbd> or <kbd>Ctrl</kbd> + <kbd>[</kbd></span></td></tr></table>diff --git a/templates/zerver/help/keyboard-shortcuts.md b/templates/zerver/help/keyboard-shortcuts.mdindex c6cc81eb4ca..53d343247a2 100644--- a/templates/zerver/help/keyboard-shortcuts.md+++ b/templates/zerver/help/keyboard-shortcuts.md@@ -22,7 +22,7 @@ below, and add more to your repertoire as needed.* **New private message**: `x`-* **Cancel compose**: `Esc` or `Ctrl` + `[` — Close the compose box and save+* **Cancel compose and save draft**: `Esc` or `Ctrl` + `[` — Close the compose box and savethe unsent message as a draft.* **View drafts**: `d` — Use the arrow keys and `Enter` to restore a draft.@@ -114,7 +114,7 @@ below, and add more to your repertoire as needed.* **Insert bold text**: `**bold**` or `Ctrl` + `B`* **Insert link**: `[Zulip website](https://zulip.org)` or `Ctrl` + `Shift` + `L`-* **Cancel compose**: `Esc` or `Ctrl` + `[` — Close the compose box and save+* **Cancel compose and save draft**: `Esc` or `Ctrl` + `[` — Close the compose box and savethe unsent message as a draft.## Message actions