From 6d3d9165b1546a0bff6d06c915b4aa60693f5499 Mon Sep 17 00:00:00 2001 From: Daniil Fadeev Date: Wed, 23 Aug 2023 23:13:38 +0300 Subject: [PATCH] emoji_picker: Rename reactions_popped to is_open. emoji_picker.is_open() much more accurately describes what this does, and in particular the fact that the function applies to all places the emoji picker might be. --- web/src/emoji_picker.js | 8 ++++---- web/src/hotkey.js | 10 +++++----- web/src/popovers.js | 2 +- web/tests/hotkey.test.js | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/web/src/emoji_picker.js b/web/src/emoji_picker.js index db08cd73e7..ccca6547d1 100644 --- a/web/src/emoji_picker.js +++ b/web/src/emoji_picker.js @@ -187,12 +187,12 @@ function refill_section_head_offsets($popover) { }); } -export function reactions_popped() { +export function is_open() { return Boolean(emoji_popover_instance); } export function hide_emoji_popover() { - if (!reactions_popped()) { + if (!is_open()) { return; } current_message_id = null; @@ -447,7 +447,7 @@ function change_focus_to_filter() { export function navigate(event_name, e) { if ( event_name === "toggle_reactions_popover" && - reactions_popped() && + is_open() && (search_is_active === false || search_results.length === 0) ) { hide_emoji_popover(); @@ -792,7 +792,7 @@ export function register_click_handlers() { e.preventDefault(); e.stopPropagation(); toggle_emoji_popover(e.target, undefined, {placement: "bottom"}); - if (reactions_popped()) { + if (is_open()) { // Because the emoji picker gets drawn on top of the user // status modal, we need this hack to make clicking outside // the emoji picker only close the emoji picker, and not the diff --git a/web/src/hotkey.js b/web/src/hotkey.js index fa91f1bbd1..f9b979a3a8 100644 --- a/web/src/hotkey.js +++ b/web/src/hotkey.js @@ -292,7 +292,7 @@ export function process_escape_key(e) { } // Emoji picker goes before compose so compose emoji picker is closed properly. - if (emoji_picker.reactions_popped()) { + if (emoji_picker.is_open()) { emoji_picker.hide_emoji_popover(); return true; } @@ -404,7 +404,7 @@ export function process_enter_key(e) { return false; } - if (emoji_picker.reactions_popped()) { + if (emoji_picker.is_open()) { return emoji_picker.navigate("enter", e); } @@ -557,7 +557,7 @@ export function process_tab_key() { return true; } - if (emoji_picker.reactions_popped()) { + if (emoji_picker.is_open()) { return emoji_picker.navigate("tab"); } @@ -593,7 +593,7 @@ export function process_shift_tab_key() { } // Shift-Tabbing from emoji catalog/search results takes you back to search textbox. - if (emoji_picker.reactions_popped()) { + if (emoji_picker.is_open()) { return emoji_picker.navigate("shift_tab"); } @@ -647,7 +647,7 @@ export function process_hotkey(e, hotkey) { // This block needs to be before the open modals check, because // the "user status" modal can show the emoji picker. - if (emoji_picker.reactions_popped()) { + if (emoji_picker.is_open()) { return emoji_picker.navigate(event_name); } diff --git a/web/src/popovers.js b/web/src/popovers.js index b13fdf60aa..5c0edbaba4 100644 --- a/web/src/popovers.js +++ b/web/src/popovers.js @@ -1070,7 +1070,7 @@ export function any_active() { stream_popover.stream_popped() || message_info_popped() || user_info_popped() || - emoji_picker.reactions_popped() || + emoji_picker.is_open() || $("[class^='column-'].expanded").length ); } diff --git a/web/tests/hotkey.test.js b/web/tests/hotkey.test.js index b6bb76363e..c931d5222b 100644 --- a/web/tests/hotkey.test.js +++ b/web/tests/hotkey.test.js @@ -37,7 +37,7 @@ const compose_actions = mock_esm("../src/compose_actions"); const condense = mock_esm("../src/condense"); const drafts = mock_esm("../src/drafts"); const emoji_picker = mock_esm("../src/emoji_picker", { - reactions_popped: () => false, + is_open: () => false, toggle_emoji_popover() {}, }); const gear_menu = mock_esm("../src/gear_menu", { @@ -418,7 +418,7 @@ run_test("v w/no overlays", ({override}) => { }); run_test("emoji picker", ({override}) => { - override(emoji_picker, "reactions_popped", () => true); + override(emoji_picker, "is_open", () => true); assert_mapping(":", emoji_picker, "navigate", true); });