mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 03:11:54 +00:00
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:
@@ -10,6 +10,7 @@ import render_narrow_tooltip from "../templates/narrow_tooltip.hbs";
|
||||
|
||||
import {$t} from "./i18n";
|
||||
import * as message_lists from "./message_lists";
|
||||
import * as popover_menus from "./popover_menus";
|
||||
import * as reactions from "./reactions";
|
||||
import * as rows from "./rows";
|
||||
import {realm} from "./state_data";
|
||||
@@ -83,7 +84,7 @@ function hide_tooltip_if_reference_removed(
|
||||
// We have to be smart about hiding the instance, so we hide it as soon
|
||||
// as it is displayed.
|
||||
setTimeout(() => {
|
||||
instance.hide();
|
||||
popover_menus.hide_current_popover_if_visible(instance);
|
||||
}, 0);
|
||||
return;
|
||||
}
|
||||
@@ -92,11 +93,11 @@ function hide_tooltip_if_reference_removed(
|
||||
for (const node of nodes_to_check_for_removal) {
|
||||
// Hide instance if reference's class changes.
|
||||
if (mutation.type === "attributes" && mutation.attributeName === "class") {
|
||||
instance.hide();
|
||||
popover_menus.hide_current_popover_if_visible(instance);
|
||||
}
|
||||
// Hide instance if reference is in the removed node list.
|
||||
if (Array.prototype.includes.call(mutation.removedNodes, node)) {
|
||||
instance.hide();
|
||||
popover_menus.hide_current_popover_if_visible(instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user