Skip to content

Commit 6fe4f51

Browse files
vaisestLocalIdentity
andauthored
Set anchor collapse on comparison tab collectors (#9876)
* Set anchor collapse on comparison tab collectors * Fix controls not being hidden on removing build --------- Co-authored-by: LocalIdentity <localidentity2@gmail.com>
1 parent d07ef7c commit 6fe4f51

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
describe("CompareTab", function()
2+
it("hides skill detail controls after removing the final comparison", function()
3+
newBuild()
4+
local compareTab = build.compareTab
5+
compareTab.compareEntries = { { label = "Test" } }
6+
compareTab.activeCompareIndex = 1
7+
local controls = {
8+
compareTab.controls.cmpMainSkill,
9+
compareTab.controls.cmpSkillPart,
10+
compareTab.controls.cmpStageCount,
11+
compareTab.controls.cmpMineCount,
12+
compareTab.controls.cmpMinion,
13+
compareTab.controls.cmpMinionSkill,
14+
}
15+
for _, control in ipairs(controls) do
16+
control.shown = true
17+
end
18+
19+
compareTab:RemoveBuild(1)
20+
21+
for _, control in ipairs(controls) do
22+
assert.is_false(control:IsShown())
23+
end
24+
end)
25+
end)

src/Classes/CompareTab.lua

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ function CompareTabClass:InitControls()
346346
-- ============================================================
347347
self.controls.cmpSkillLabel = new("LabelControl", {"TOPLEFT", self.controls.subTabAnchor, "TOPLEFT"}, {0, -32, 0, 16}, "^7Skill:")
348348
self.controls.cmpSkillLabel.shown = setsEnabled
349+
self.controls.cmpSkillLabel.anchor.collapse = true
349350

350351
-- Socket group dropdown
351352
self.controls.cmpSocketGroup = new("DropDownControl", {"LEFT", self.controls.cmpSkillLabel, "RIGHT"}, {4, 0, 200, 20}, {}, function(index, value)
@@ -357,6 +358,7 @@ function CompareTabClass:InitControls()
357358
self.controls.cmpSocketGroup.shown = setsEnabled
358359
self.controls.cmpSocketGroup.maxDroppedWidth = 500
359360
self.controls.cmpSocketGroup.enableDroppedWidth = true
361+
self.controls.cmpSocketGroup.anchor.collapse = true
360362

361363
-- Active skill within group
362364
self.controls.cmpMainSkill = new("DropDownControl", {"LEFT", self.controls.cmpSocketGroup, "RIGHT"}, {4, 0, 225, 20}, {}, function(index, value)
@@ -370,6 +372,7 @@ function CompareTabClass:InitControls()
370372
end
371373
end)
372374
self.controls.cmpMainSkill.shown = false
375+
self.controls.cmpMainSkill.anchor.collapse = true
373376

374377
-- Skill part (multi-part skills)
375378
self.controls.cmpSkillPart = new("DropDownControl", {"LEFT", self.controls.cmpMainSkill, "RIGHT"}, {4, 0, 200, 20}, {}, function(index, value)
@@ -387,10 +390,12 @@ function CompareTabClass:InitControls()
387390
end
388391
end)
389392
self.controls.cmpSkillPart.shown = false
393+
self.controls.cmpSkillPart.anchor.collapse = true
390394

391395
-- Stage count
392396
self.controls.cmpStageCountLabel = new("LabelControl", {"LEFT", self.controls.cmpSkillPart, "RIGHT"}, {6, 0, 0, 16}, "^7Stages:")
393397
self.controls.cmpStageCountLabel.shown = function() return self.controls.cmpStageCount.shown end
398+
self.controls.cmpStageCountLabel.anchor.collapse = true
394399
self.controls.cmpStageCount = new("EditControl", {"LEFT", self.controls.cmpStageCountLabel, "RIGHT"}, {4, 0, 52, 20}, "", nil, "%D", 5, function(buf)
395400
local entry = self:GetActiveCompare()
396401
if entry then
@@ -406,10 +411,12 @@ function CompareTabClass:InitControls()
406411
end
407412
end)
408413
self.controls.cmpStageCount.shown = false
414+
self.controls.cmpStageCount.anchor.collapse = true
409415

410416
-- Mine count
411417
self.controls.cmpMineCountLabel = new("LabelControl", {"LEFT", self.controls.cmpStageCount, "RIGHT"}, {6, 0, 0, 16}, "^7Mines:")
412418
self.controls.cmpMineCountLabel.shown = function() return self.controls.cmpMineCount.shown end
419+
self.controls.cmpMineCountLabel.anchor.collapse = true
413420
self.controls.cmpMineCount = new("EditControl", {"LEFT", self.controls.cmpMineCountLabel, "RIGHT"}, {4, 0, 52, 20}, "", nil, "%D", 5, function(buf)
414421
local entry = self:GetActiveCompare()
415422
if entry then
@@ -425,6 +432,7 @@ function CompareTabClass:InitControls()
425432
end
426433
end)
427434
self.controls.cmpMineCount.shown = false
435+
self.controls.cmpMineCount.anchor.collapse = true
428436

429437
-- Minion selector
430438
self.controls.cmpMinion = new("DropDownControl", {"LEFT", self.controls.cmpMineCount, "RIGHT"}, {6, 0, 140, 20}, {}, function(index, value)
@@ -449,6 +457,7 @@ function CompareTabClass:InitControls()
449457
end
450458
end)
451459
self.controls.cmpMinion.shown = false
460+
self.controls.cmpMinion.anchor.collapse = true
452461

453462
-- Minion skill selector
454463
self.controls.cmpMinionSkill = new("DropDownControl", {"LEFT", self.controls.cmpMinion, "RIGHT"}, {4, 0, 140, 20}, {}, function(index, value)
@@ -466,6 +475,7 @@ function CompareTabClass:InitControls()
466475
end
467476
end)
468477
self.controls.cmpMinionSkill.shown = false
478+
self.controls.cmpMinionSkill.anchor.collapse = true
469479

470480
-- ============================================================
471481
-- Calcs view skill detail controls (per-build, independent of sidebar & regular Calcs tab)
@@ -1264,6 +1274,12 @@ function CompareTabClass:RemoveBuild(index)
12641274
if self.activeCompareIndex == 0 and #self.compareEntries > 0 then
12651275
self.activeCompareIndex = 1
12661276
end
1277+
if #self.compareEntries == 0 then
1278+
for _, control in ipairs({ self.controls.cmpMainSkill, self.controls.cmpSkillPart, self.controls.cmpStageCount,
1279+
self.controls.cmpMineCount, self.controls.cmpMinion, self.controls.cmpMinionSkill }) do
1280+
control.shown = false
1281+
end
1282+
end
12671283
self:UpdateBuildSelector()
12681284
end
12691285
end

0 commit comments

Comments
 (0)