import {ModifierArguments, State} from '@popperjs/core'; type ModifierFn = (args: ModifierArguments) => State; /** * Factory of a modifier that forces all PopperJS instances to be updated, the target object of Which is * current popper (or its child elements) * * Temporary fix for a pop-up window display error with the target object * there is another pop-up window when scrolling * * @param poppers registry Of all active popperjs instances * @param paper Key Unique identifier for the Popover instance (and the Paper JS created by It) */ type CreateUpdateChildPoppersModifier = (poppers: {[poperKey: string]: any}, popperKey: string) => ModifierFn; export const createUpdateChildPoppersModifier: CreateUpdateChildPoppersModifier = (poppers, popperKey) => { return (data) => { poppers[popperKey] = data.instance; Object.values(poppers) .filter((popper) => { return ( // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore data.state.elements.reference.contains(popper.reference as Node) || data.state.elements.popper === popper.reference ); }) .forEach((popper) => { popper.update(); }); return data.state; }; }; /** * Hide if visibility: hidden is set for the target object * * Temporary fix for a pop-up window display error with the target object * there is another pop-up window when scrolling. */ export const hideWhenReferenceHidden: ModifierFn = (data) => { const isReferenceHidden = data.state.attributes?.popper['data-popper-reference-hidden']; if (isReferenceHidden) { data.state.styles.popper.visibility = 'hidden'; } else { data.state.styles.popper.visibility = 'visible'; } return data.state; };