popover_menus: Fix event handler trying to hide a hidden popover.

When user is trying to open a modal after clicking on a button
in a popover, we call popovers.hide_all() before opening the modal
which hides the popover but since the event handler call isn't
finished running yet, we call instance.hide() again resulting in
tippy throwing errors that this could be a memory leak.

We introduce a wrapper function for `instance.hide` which if
the popover/tooltip is visible before hiding it to fix it.
This commit is contained in:
Aman Agrawal
2024-04-02 07:29:56 +00:00
committed by Tim Abbott
parent ac5161f439
commit 0a90a13bec
12 changed files with 62 additions and 51 deletions

View File

@@ -12,7 +12,7 @@ import * as blueslip from "./blueslip";
import * as ListWidget from "./list_widget";
import type {ListWidget as ListWidgetType} from "./list_widget";
import {page_params} from "./page_params";
import {default_popover_props} from "./popover_menus";
import * as popover_menus from "./popover_menus";
import type {StreamSubscription} from "./sub_store";
import {parse_html} from "./ui_util";
@@ -180,7 +180,7 @@ export class DropdownWidget {
return;
}
this.instance = tippy.delegate(delegate_container, {
...default_popover_props,
...popover_menus.default_popover_props,
target: this.widget_selector,
// Custom theme defined in popovers.css
theme: "dropdown-widget",
@@ -286,7 +286,7 @@ export class DropdownWidget {
break;
case "Escape":
instance.hide();
popover_menus.hide_current_popover_if_visible(instance);
this.on_exit_with_escape_callback();
e.stopPropagation();
e.preventDefault();