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.

drafts-ui: Fix pressing "Enter" when there are no drafts.

Sahil Batra2a09a66f2d54
diff --git a/web/src/drafts_overlay_ui.ts b/web/src/drafts_overlay_ui.ts
index 3a15bf12487..d9727a07bf7 100644
--- a/web/src/drafts_overlay_ui.ts
+++ b/web/src/drafts_overlay_ui.ts
@@ -169,6 +169,12 @@ const keyboard_handling_context: messages_overlay_ui.Context = {
// This handles when pressing Enter while looking at drafts.
// It restores draft that is focused.
const draft_id_arrow = this.get_items_ids();
+
+ if (draft_id_arrow.length === 0) {
+ // Do nothing if there are no drafts.
+ return;
+ }
+
const focused_draft_id = messages_overlay_ui.get_focused_element_id(this);
if (focused_draft_id !== undefined) {
restore_draft(focused_draft_id);