mirror of https://github.com/zulip/zulip.git
playground_popover: Fix bug where the playground popover doesn't reopen.
This commit fixes a bug where the popover doesn't reopen after it's closed. The bug was caused since `playground_links_popover_instance` wasn't being set to `null` after the popover was closed, which led the `is_open` function to return `true` even when the popover was closed.
This commit is contained in:
parent
fe1f8afb1b
commit
5191a80a3a
|
@ -12,7 +12,7 @@ import * as ui_util from "./ui_util";
|
|||
|
||||
type RealmPlaygroundWithURL = RealmPlayground & {playground_url: string};
|
||||
|
||||
let playground_links_popover_instance: tippy.Instance;
|
||||
let playground_links_popover_instance: tippy.Instance | null = null;
|
||||
|
||||
// Playground_store contains all the data we need to generate a popover of
|
||||
// playground links for each code block. The element is the target element
|
||||
|
@ -63,16 +63,19 @@ export function is_open(): boolean {
|
|||
}
|
||||
|
||||
export function hide(): void {
|
||||
if (is_open()) {
|
||||
$(playground_links_popover_instance.reference)
|
||||
.parent()
|
||||
.removeClass("active-playground-links-reference");
|
||||
playground_links_popover_instance.destroy();
|
||||
if (!playground_links_popover_instance) {
|
||||
return;
|
||||
}
|
||||
|
||||
$(playground_links_popover_instance.reference)
|
||||
.parent()
|
||||
.removeClass("active-playground-links-reference");
|
||||
playground_links_popover_instance.destroy();
|
||||
playground_links_popover_instance = null;
|
||||
}
|
||||
|
||||
function get_playground_links_popover_items(): JQuery | undefined {
|
||||
if (!is_open()) {
|
||||
if (!playground_links_popover_instance) {
|
||||
blueslip.error("Trying to get menu items when playground links popover is closed.");
|
||||
return undefined;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue