mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 19:31:58 +00:00
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:
@@ -561,13 +561,13 @@ function get_action_menu_menu_items() {
|
|||||||
return $("li:not(.divider):visible a", popover_data.$tip);
|
return $("li:not(.divider):visible a", popover_data.$tip);
|
||||||
}
|
}
|
||||||
|
|
||||||
function focus_first_popover_item(items) {
|
exports.focus_first_popover_item = (items) => {
|
||||||
if (!items) {
|
if (!items) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
items.eq(0).expectOne().trigger("focus");
|
items.eq(0).expectOne().trigger("focus");
|
||||||
}
|
};
|
||||||
|
|
||||||
function popover_items_handle_keyboard(key, items) {
|
function popover_items_handle_keyboard(key, items) {
|
||||||
if (!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.
|
// 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.
|
// Our popup menus act kind of funny when you mix keyboard and mouse.
|
||||||
const items = get_action_menu_menu_items();
|
const items = get_action_menu_menu_items();
|
||||||
focus_first_popover_item(items);
|
exports.focus_first_popover_item(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.open_message_menu = function (message) {
|
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.
|
// 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.
|
// Our popup menus act kind of funny when you mix keyboard and mouse.
|
||||||
const items = get_user_info_popover_items();
|
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) {
|
exports.user_info_popover_handle_keyboard = function (key) {
|
||||||
|
|||||||
Reference in New Issue
Block a user