mirror of https://github.com/zulip/zulip.git
modals: Fix focus for recent_view_ui and inbox_ui modals.
Earlier the focus was not being set to the modal when it was opened. This was because `is_in_focus` checks if `modals.any_active` which checks `$(".micromodal").hasClass("modal--open")`. But when `is_in_focus` is called `$(".micromodal").hasClass("modal--opening")`. This commit fixes the issue by creating a function `is_active_or_animating` which checks if the modal has the class `modal--open` or `modal--opening`.
This commit is contained in:
parent
dc85478c5d
commit
fccc338db5
|
@ -212,6 +212,9 @@ export function show(): void {
|
||||||
on_click() {
|
on_click() {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
},
|
},
|
||||||
|
on_hidden() {
|
||||||
|
revive_current_focus();
|
||||||
|
},
|
||||||
single_footer_button: true,
|
single_footer_button: true,
|
||||||
focus_submit_on_open: true,
|
focus_submit_on_open: true,
|
||||||
});
|
});
|
||||||
|
@ -831,6 +834,9 @@ function focus_clicked_list_element($elt: JQuery): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function revive_current_focus(): void {
|
export function revive_current_focus(): void {
|
||||||
|
if (!is_in_focus()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (is_list_focused()) {
|
if (is_list_focused()) {
|
||||||
set_list_focus();
|
set_list_focus();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -32,6 +32,11 @@ function call_hooks(func_list: Hook[]): void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function any_active_or_animating(): boolean {
|
||||||
|
const $active_modal = $(".micromodal");
|
||||||
|
return $active_modal.hasClass("modal--open") || $active_modal.hasClass("modal--opening");
|
||||||
|
}
|
||||||
|
|
||||||
export function any_active(): boolean {
|
export function any_active(): boolean {
|
||||||
return $(".micromodal").hasClass("modal--open");
|
return $(".micromodal").hasClass("modal--open");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1350,6 +1350,9 @@ export function show(): void {
|
||||||
on_click() {
|
on_click() {
|
||||||
/* This widget is purely informational and clicking only closes it. */
|
/* This widget is purely informational and clicking only closes it. */
|
||||||
},
|
},
|
||||||
|
on_hidden() {
|
||||||
|
revive_current_focus();
|
||||||
|
},
|
||||||
single_footer_button: true,
|
single_footer_button: true,
|
||||||
focus_submit_on_open: true,
|
focus_submit_on_open: true,
|
||||||
});
|
});
|
||||||
|
|
|
@ -145,7 +145,7 @@ export function is_in_focus(): boolean {
|
||||||
!popovers.any_active() &&
|
!popovers.any_active() &&
|
||||||
!sidebar_ui.any_sidebar_expanded_as_overlay() &&
|
!sidebar_ui.any_sidebar_expanded_as_overlay() &&
|
||||||
!overlays.any_active() &&
|
!overlays.any_active() &&
|
||||||
!modals.any_active() &&
|
!modals.any_active_or_animating() &&
|
||||||
!$(".home-page-input").is(":focus") &&
|
!$(".home-page-input").is(":focus") &&
|
||||||
!$("#search_query").is(":focus")
|
!$("#search_query").is(":focus")
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue