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

This commit fixes an assertion error on pressing "Enter" in
drafts UI when there are no drafts.
This commit is contained in:
Sahil Batra
2025-07-29 12:36:00 +05:30
committed by Tim Abbott
parent 6c625a0177
commit 2a09a66f2d

View File

@@ -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);