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.
This commit is contained in:
Aman Agrawal
2025-03-18 17:58:27 +05:30
committed by Tim Abbott
parent 1314aec7e1
commit d14b1b1085

View File

@@ -212,8 +212,10 @@ export const default_popover_props: Partial<tippy.Props> = {
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