Fix error about pinnable tooltips

This commit is contained in:
thepaperpilot 2023-05-20 08:28:27 -05:00
parent 210c2290f0
commit d6c9f95851
2 changed files with 2 additions and 13 deletions

View file

@ -37,7 +37,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
color,
reset
}));
addTooltip(treeNode, {
const tooltip = addTooltip(treeNode, {
display: createResourceTooltip(points),
pinnable: true
});
@ -58,6 +58,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
name,
color,
points,
tooltip,
display: jsx(() => (
<>
<MainDisplay resource={points} color={color} />

View file

@ -95,18 +95,6 @@ export function addTooltip<T extends TooltipOptions>(
}
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];
element[Component] = TooltipComponent as GenericComponent;
const elementGatherProps = element[GatherProps].bind(element);