From e96c47a739b0594b56a5c447a599f9193dbaa416 Mon Sep 17 00:00:00 2001 From: Xurkon Date: Fri, 12 Jun 2026 22:43:10 -0500 Subject: [PATCH] fix: show learner tooltips in auto mode --- Modules/QuestieLearner.lua | 15 +++++++++++- Modules/Tooltips/Tooltip.lua | 5 +++- Tests/QuestieLearnerTooltipMode_spec.lua | 30 ++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 Tests/QuestieLearnerTooltipMode_spec.lua diff --git a/Modules/QuestieLearner.lua b/Modules/QuestieLearner.lua index f97c34d..225ce60 100644 --- a/Modules/QuestieLearner.lua +++ b/Modules/QuestieLearner.lua @@ -586,6 +586,12 @@ function QuestieLearner:IsLearnerLiveEnabled() return mode == "auto" or mode == "learner" end +function QuestieLearner:CanShowLearnerTooltips() + if not EnsureLearnedData() then return false end + local mode = self:GetDataSourceMode() + return mode == "auto" or mode == "learner" +end + function QuestieLearner:ApplyDataSourceMode() if not EnsureLearnedData() then return end local settings = Questie.dbLearner and Questie.dbLearner.global and Questie.dbLearner.global.settings @@ -4901,7 +4907,7 @@ end local function _ShowLearnerTooltipFrame(sourceTooltip, lines) local tooltip = _GetLearnerTooltipFrame() tooltip:ClearLines() - tooltip:SetOwner(sourceTooltip or GameTooltip, "ANCHOR_RIGHT") + tooltip:SetOwner(UIParent, "ANCHOR_NONE") for _, line in next, lines do tooltip:AddLine(line) end @@ -4909,6 +4915,9 @@ local function _ShowLearnerTooltipFrame(sourceTooltip, lines) if QuestieTooltips and QuestieTooltips.ResizeTooltip then QuestieTooltips:ResizeTooltip(tooltip) end + local anchor = sourceTooltip or GameTooltip + tooltip:ClearAllPoints() + tooltip:SetPoint("TOPLEFT", anchor, "BOTTOMLEFT", 0, -2) tooltip:Show() end @@ -4921,6 +4930,10 @@ local function _AddLearnedSpawnTooltipLine(unitToken) _HideLearnerTooltipFrame() return end + if not QuestieLearner:CanShowLearnerTooltips() then + _HideLearnerTooltipFrame() + return + end if not Questie.db.profile or Questie.db.profile.learnerTooltips == false then _HideLearnerTooltipFrame() return diff --git a/Modules/Tooltips/Tooltip.lua b/Modules/Tooltips/Tooltip.lua index c0ad925..85a8843 100644 --- a/Modules/Tooltips/Tooltip.lua +++ b/Modules/Tooltips/Tooltip.lua @@ -302,7 +302,10 @@ local function _GetLearnerTooltipLines(key) if not id then return nil end local QuestieLearner = QuestieLoader:ImportModule("QuestieLearner") - if not QuestieLearner or not QuestieLearner.IsEnabled or not QuestieLearner:IsEnabled() then + if not QuestieLearner + or not QuestieLearner.CanShowLearnerTooltips + or not QuestieLearner:CanShowLearnerTooltips() + then return nil end diff --git a/Tests/QuestieLearnerTooltipMode_spec.lua b/Tests/QuestieLearnerTooltipMode_spec.lua new file mode 100644 index 0000000..b84b840 --- /dev/null +++ b/Tests/QuestieLearnerTooltipMode_spec.lua @@ -0,0 +1,30 @@ +local function read(path) + local f = assert(io.open(path, "r"), "cannot open " .. path) + local c = f:read("*a") + f:close() + return c +end + +local function has(content, needle) + return string.find(content, needle, 1, true) ~= nil +end + +describe("QuestieLearner tooltip mode and anchoring", function() + local learner = read("Modules/QuestieLearner.lua") + local tooltip = read("Modules/Tooltips/Tooltip.lua") + + it("allows learned tooltip data in auto and learner modes", function() + assert.is_true(has(learner, "function QuestieLearner:CanShowLearnerTooltips()")) + assert.is_true(has(learner, "return mode == \"auto\" or mode == \"learner\"")) + assert.is_true(has(tooltip, "QuestieLearner:CanShowLearnerTooltips()")) + assert.is_false(has(tooltip, "QuestieLearner:IsEnabled()")) + end) + + it("anchors the secondary learner tooltip under the default tooltip", function() + assert.is_true(has(learner, "tooltip:SetOwner(UIParent, \"ANCHOR_NONE\")")) + assert.is_true(has(learner, "local anchor = sourceTooltip or GameTooltip")) + assert.is_true(has(learner, "tooltip:ClearAllPoints()")) + assert.is_true(has(learner, "tooltip:SetPoint(\"TOPLEFT\", anchor, \"BOTTOMLEFT\", 0, -2)")) + assert.is_false(has(learner, "tooltip:SetOwner(sourceTooltip or GameTooltip, \"ANCHOR_RIGHT\")")) + end) +end)