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.
This commit is contained in:
Mohit Gupta
2020-07-09 00:22:53 +05:30
committed by Tim Abbott
parent f266b52469
commit 6bccadd0b6

View File

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