Fix tooltips sometimes causing issues with cyclical dependencies

This commit is contained in:
thepaperpilot 2022-04-24 16:44:37 -05:00
parent eb06435821
commit 819c3c674a

View file

@ -15,7 +15,7 @@ import {
ProcessedComputable
} from "util/computed";
import { VueFeature } from "util/vue";
import { Ref, unref } from "vue";
import { nextTick, Ref, unref } from "vue";
import { persistent } from "game/persistence";
declare module "@vue/runtime-dom" {
@ -73,6 +73,15 @@ export function addTooltip<T extends TooltipOptions>(
element: VueFeature,
options: T & ThisType<Tooltip<T>> & Partial<BaseTooltip>
): Tooltip<T> {
processComputable(options as T, "display");
processComputable(options as T, "classes");
processComputable(options as T, "style");
processComputable(options as T, "direction");
setDefault(options, "direction", TooltipDirection.UP);
processComputable(options as T, "xoffset");
processComputable(options as T, "yoffset");
nextTick(() => {
if (options.pinnable) {
if ("pinned" in element) {
console.error(
@ -85,14 +94,6 @@ export function addTooltip<T extends TooltipOptions>(
}
}
processComputable(options as T, "display");
processComputable(options as T, "classes");
processComputable(options as T, "style");
processComputable(options as T, "direction");
setDefault(options, "direction", TooltipDirection.UP);
processComputable(options as T, "xoffset");
processComputable(options as T, "yoffset");
const elementComponent = element[Component];
element[Component] = TooltipComponent;
const elementGratherProps = element[GatherProps].bind(element);
@ -112,6 +113,7 @@ export function addTooltip<T extends TooltipOptions>(
pinned
};
}.bind(options as GenericTooltip);
});
return options as unknown as Tooltip<T>;
}