mirror of https://github.com/zulip/zulip.git
user_card_popover: Fix keyboard navigation opening manage menu.
`focus_first_popover_item` was executed right after the click handler had asked to open the popover, but before the popover was mounted to the DOM, causing the popover to not work correctly when opened via the keyboard.
This commit is contained in:
parent
0ab788c9c9
commit
bb58fecf28
|
@ -58,8 +58,28 @@ export function popover_items_handle_keyboard(key, $items) {
|
||||||
if (key === "enter" && index >= 0 && index < $items.length) {
|
if (key === "enter" && index >= 0 && index < $items.length) {
|
||||||
$items[index].click();
|
$items[index].click();
|
||||||
if (user_card_popover.manage_menu.is_open()) {
|
if (user_card_popover.manage_menu.is_open()) {
|
||||||
const $items = user_card_popover.get_user_card_popover_manage_menu_items();
|
// If we just opened the little manage menu via the
|
||||||
focus_first_popover_item($items);
|
// keyboard, we need to focus the first item for a
|
||||||
|
// continuation of the keyboard experience.
|
||||||
|
|
||||||
|
// TODO: This might be cleaner to just call
|
||||||
|
// toggle_user_card_popover_manage_menu rather than
|
||||||
|
// triggering a click.
|
||||||
|
|
||||||
|
const previously_defined_on_mount =
|
||||||
|
user_card_popover.manage_menu.instance.props.onMount;
|
||||||
|
user_card_popover.manage_menu.instance.setProps({
|
||||||
|
onMount() {
|
||||||
|
// We're monkey patching the onMount method here to ensure we start
|
||||||
|
// focusing on the item after the popover is mounted to the DOM;
|
||||||
|
// otherwise, it won't work correctly.
|
||||||
|
if (previously_defined_on_mount) {
|
||||||
|
previously_defined_on_mount();
|
||||||
|
}
|
||||||
|
const $items = user_card_popover.get_user_card_popover_manage_menu_items();
|
||||||
|
focus_first_popover_item($items);
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue