dropdown_widget: Fix dropdown not displayed on mobile.

This was due to reference being hidden by keyboard or scrolled
offscreen. We fix it by showing the dropdown even if the reference
is hidden for mobile devices.
This commit is contained in:
Aman Agrawal
2024-07-12 11:49:22 +00:00
committed by Tim Abbott
parent ebf9105a51
commit e75ac2bfd1

View File

@@ -15,6 +15,7 @@ import {page_params} from "./page_params";
import * as popover_menus from "./popover_menus";
import type {StreamSubscription} from "./sub_store";
import {parse_html} from "./ui_util";
import * as util from "./util";
/* Sync with max-height set in zulip.css */
export const DEFAULT_DROPDOWN_HEIGHT = 210;
@@ -191,6 +192,14 @@ export class DropdownWidget {
theme: "dropdown-widget",
arrow: false,
onShow: (instance: tippy.Instance) => {
if (util.is_mobile()) {
// The dropdown trigger button can be hidden by the
// keyboard on mobile or if it is scrolled out of
// view to keyboard being displayed.
// So, we show the dropdown even if reference is hidden on
// mobile.
$(instance.popper).find(".tippy-box").addClass("show-when-reference-hidden");
}
instance.setContent(
parse_html(
render_dropdown_list_container({