From 528afc6b590edf235e6c6f26433594bd32a6e8b4 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Sun, 2 Apr 2023 22:09:13 -0500 Subject: [PATCH] Fix tooltips being pinnable causing SO --- src/features/tooltips/tooltip.ts | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/features/tooltips/tooltip.ts b/src/features/tooltips/tooltip.ts index 13cb931..2cb977d 100644 --- a/src/features/tooltips/tooltip.ts +++ b/src/features/tooltips/tooltip.ts @@ -1,6 +1,6 @@ import type { CoercableComponent, Replace, StyleValue } 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 type { Computable, @@ -71,18 +71,22 @@ export function addTooltip( processComputable(options as T, "yoffset"); 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; - } else { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (element as any).pinned = options.pinned = persistent(false, false); - } + options.pinned = persistent(false, false); } 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); + } else { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (element as any).pinned = options.pinned; + } + } const elementComponent = element[Component]; element[Component] = TooltipComponent; const elementGatherProps = element[GatherProps].bind(element);