Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
tenor: Focus edit textarea on closing tenor picker with esc.
apoorvapendsed37a4fec2d28
diff --git a/web/src/hotkey.ts b/web/src/hotkey.tsindex c7f31b3a1dc..7a67e0c898b 100644--- a/web/src/hotkey.ts+++ b/web/src/hotkey.ts@@ -59,6 +59,7 @@ import {realm} from "./state_data.ts";import * as stream_list from "./stream_list.ts";import * as stream_popover from "./stream_popover.ts";import * as stream_settings_ui from "./stream_settings_ui.ts";+import * as tenor from "./tenor.ts";import * as topic_list from "./topic_list.ts";import * as unread_ops from "./unread_ops.ts";import * as user_card_popover from "./user_card_popover.ts";@@ -427,6 +428,14 @@ function process_escape_key(e: JQuery.KeyDownEvent): boolean {return true;}+ if (tenor.is_popped_from_edit_message()) {+ tenor.focus_current_edit_message();+ // Hide after setting focus so that `edit_message_id` is+ // still set in giphy.+ tenor.hide_tenor_popover();+ return true;+ }+if (popovers.any_active()) {popovers.hide_all();return true;diff --git a/web/src/tenor.ts b/web/src/tenor.tsindex be10e7766a9..61b90bab65e 100644--- a/web/src/tenor.ts+++ b/web/src/tenor.ts@@ -64,6 +64,15 @@ type TenorPayload = {q?: string;};+export function is_popped_from_edit_message(): boolean {+ return tenor_popover_instance !== undefined && edit_message_id !== undefined;+}++export function focus_current_edit_message(): void {+ assert(edit_message_id !== undefined);+ $(`#edit_form_${CSS.escape(`${edit_message_id}`)} .message_edit_content`).trigger("focus");+}+function get_base_payload(): TenorPayload {return {key: realm.tenor_api_key,@@ -144,7 +153,7 @@ function handle_keyboard_navigation_on_gif(e: JQuery.KeyDownEvent): void {}}-function hide_tenor_popover(): boolean {+export function hide_tenor_popover(): boolean {// Returns `true` if the popover was open.if (tenor_popover_instance) {tenor_popover_instance.destroy();