forked from profectus/Profectus
Fix tooltips being pinnable causing SO
This commit is contained in:
parent
572566c4c1
commit
528afc6b59
1 changed files with 14 additions and 10 deletions
|
@ -1,6 +1,6 @@
|
||||||
import type { CoercableComponent, Replace, StyleValue } from "features/feature";
|
import type { CoercableComponent, Replace, StyleValue } from "features/feature";
|
||||||
import { Component, GatherProps, setDefault } from "features/feature";
|
import { Component, GatherProps, setDefault } from "features/feature";
|
||||||
import { persistent } from "game/persistence";
|
import { deletePersistent, Persistent, persistent } from "game/persistence";
|
||||||
import { Direction } from "util/common";
|
import { Direction } from "util/common";
|
||||||
import type {
|
import type {
|
||||||
Computable,
|
Computable,
|
||||||
|
@ -71,18 +71,22 @@ export function addTooltip<T extends TooltipOptions>(
|
||||||
processComputable(options as T, "yoffset");
|
processComputable(options as T, "yoffset");
|
||||||
|
|
||||||
if (options.pinnable) {
|
if (options.pinnable) {
|
||||||
if ("pinned" in element) {
|
options.pinned = persistent<boolean>(false, false);
|
||||||
console.error(
|
|
||||||
"Cannot add pinnable tooltip to element that already has a property called 'pinned'"
|
|
||||||
);
|
|
||||||
options.pinnable = false;
|
|
||||||
} else {
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
(element as any).pinned = options.pinned = persistent<boolean>(false, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
|
if (options.pinnable) {
|
||||||
|
if ("pinned" in element) {
|
||||||
|
console.error(
|
||||||
|
"Cannot add pinnable tooltip to element that already has a property called 'pinned'"
|
||||||
|
);
|
||||||
|
options.pinnable = false;
|
||||||
|
deletePersistent(options.pinned as Persistent<boolean>);
|
||||||
|
} else {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
(element as any).pinned = options.pinned;
|
||||||
|
}
|
||||||
|
}
|
||||||
const elementComponent = element[Component];
|
const elementComponent = element[Component];
|
||||||
element[Component] = TooltipComponent;
|
element[Component] = TooltipComponent;
|
||||||
const elementGatherProps = element[GatherProps].bind(element);
|
const elementGatherProps = element[GatherProps].bind(element);
|
||||||
|
|
Loading…
Reference in a new issue