From d14b1b1085cc8d89bbeb723417a6bc41713004c0 Mon Sep 17 00:00:00 2001 From: Aman Agrawal Date: Tue, 18 Mar 2025 17:58:27 +0530 Subject: [PATCH] popover_menus: Fix tippy `instance` being undefined. Since the reference element can be removed from DOM, we rely on `popper` here to access the tippy instance which is reliable. --- web/src/popover_menus.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/web/src/popover_menus.ts b/web/src/popover_menus.ts index 90442d4491..ae8adf7f40 100644 --- a/web/src/popover_menus.ts +++ b/web/src/popover_menus.ts @@ -212,8 +212,10 @@ export const default_popover_props: Partial = { phase: "beforeWrite", requires: ["$$tippy"], fn({state}) { + // Since the reference element can be removed from DOM, we rely on popper + // here to access the tippy instance which is reliable. // eslint-disable-next-line @typescript-eslint/consistent-type-assertions - const instance = (state.elements.reference as tippy.ReferenceElement)._tippy!; + const instance = (state.elements.popper as tippy.PopperElement)._tippy!; const $popover = $(state.elements.popper); const $tippy_box = $popover.find(".tippy-box"); // $tippy_box[0].hasAttribute("data-reference-hidden"); is the real check