From 6bccadd0b6d7f8c76f542e1bba61f54823e4cbbd Mon Sep 17 00:00:00 2001 From: Mohit Gupta Date: Thu, 9 Jul 2020 00:22:53 +0530 Subject: [PATCH] popovers: Export focus_first_popover_item function from popovers.js. This commit is preparatory commit to adding support for keyboard navigation by focusing om first menu item of all of our popovers. So exporting focus_first_popover_item so that it can be reused in other places. --- static/js/popovers.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/static/js/popovers.js b/static/js/popovers.js index c58503a745..887b2c937c 100644 --- a/static/js/popovers.js +++ b/static/js/popovers.js @@ -561,13 +561,13 @@ function get_action_menu_menu_items() { return $("li:not(.divider):visible a", popover_data.$tip); } -function focus_first_popover_item(items) { +exports.focus_first_popover_item = (items) => { if (!items) { return; } items.eq(0).expectOne().trigger("focus"); -} +}; function popover_items_handle_keyboard(key, items) { if (!items) { @@ -593,7 +593,7 @@ function focus_first_action_popover_item() { // For now I recommend only calling this when the user opens the menu with a hotkey. // Our popup menus act kind of funny when you mix keyboard and mouse. const items = get_action_menu_menu_items(); - focus_first_popover_item(items); + exports.focus_first_popover_item(items); } exports.open_message_menu = function (message) { @@ -687,7 +687,7 @@ function focus_user_info_popover_item() { // For now I recommend only calling this when the user opens the menu with a hotkey. // Our popup menus act kind of funny when you mix keyboard and mouse. const items = get_user_info_popover_items(); - focus_first_popover_item(items); + exports.focus_first_popover_item(items); } exports.user_info_popover_handle_keyboard = function (key) {