Skip to content

A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.

Accessibility: Tab no longer leaves the advisor media overlay for the popup behind it (Refs #2340) (#2910)

Beri53b48b770607
diff --git a/changelog.d/2340-advisor-overlay-tab.md b/changelog.d/2340-advisor-overlay-tab.md
new file mode 100644
index 000000000..df80cf3a5
--- /dev/null
+++ b/changelog.d/2340-advisor-overlay-tab.md
@@ -0,0 +1,4 @@
+### Fixed
+
+- With an advisor's picture open over the game, Tab no longer leaves it for the advisor's popup behind it. The popup
+ is out of reach until the picture closes, then it is as it was. (#2340)
diff --git a/unity/Assets/Scripts/UI/AdvisorPresenter.cs b/unity/Assets/Scripts/UI/AdvisorPresenter.cs
index a73355b93..543b57a65 100644
--- a/unity/Assets/Scripts/UI/AdvisorPresenter.cs
+++ b/unity/Assets/Scripts/UI/AdvisorPresenter.cs
@@ -693,6 +693,8 @@ namespace Statecraft.Game.UI
hudRoot.EnableInClassList(OverlayOpenClass, !inline);
if (!inline)
{
+ // The popup too: it stays on screen behind the overlay, and Tab would leave the overlay for its buttons (#2340).
+ overlayCoveredScreens.Add((popup, popup.enabledSelf)); popup.SetEnabled(false);
foreach (var name in ScreenNav.Screens)
if (hudRoot.Q("screen-" + name) is VisualElement screen) { overlayCoveredScreens.Add((screen, screen.enabledSelf)); screen.SetEnabled(false); }
ScreenNav.DisableCovered(hudRoot); FocusReturn.To(overlayClose);
diff --git a/unity/Assets/Tests/EditMode/AdvisorMediaTests.cs b/unity/Assets/Tests/EditMode/AdvisorMediaTests.cs
index becea3beb..ae7b853ad 100644
--- a/unity/Assets/Tests/EditMode/AdvisorMediaTests.cs
+++ b/unity/Assets/Tests/EditMode/AdvisorMediaTests.cs
@@ -221,6 +221,34 @@ public class AdvisorMediaTests
Assert.AreEqual("budget", rig.Nav.Current, "Escape closes only the overlay, not the screen under it");
Assert.IsFalse(rig.Advisor.CloseOverlay(), "nothing to close");
}
+ /// <summary>#2340: Tab left the overlay for the advisor popup behind it (the overlay disabled the screens it covers, not the
+ /// popup). The popup, and so its buttons, is out of reach while the overlay is open and comes back, as it was, when it closes.</summary>
+ [Test]
+ public void TheOverlayTakesTheAdvisorPopupOutOfTabReachAndGivesItBack()
+ {
+ foreach (var hebrew in new[] { false, true })
+ {
+ using var rig = new AdvisorPopupTests.Rig(catalog: AdvisorPopupTests.Fixture.Replace("level: new,", "level: new, he_review: approved,"), text: hebrew ? HebrewText : Text);
+ rig.HudRoot.EnableInClassList(UiLanguage.HebrewClass, hebrew);
+ var pic = new FakePicture { Ready = true }; var output = new FakeOutput();
+ rig.Advisor.Media = new AdvisorMedia(hebrew ? HebrewText : Text, pic, null, Immediate, output);
+ rig.Advisor.ForceInline = false;
+ rig.Advisor.NewGame();
+ var popup = rig.Ui.Q<VisualElement>("advisor-popup"); var gotIt = rig.Ui.Q<Button>("advisor-got-it");
+ string lang = hebrew ? "Hebrew: " : "English: ";
+ Assert.IsTrue(popup.enabledInHierarchy && gotIt.enabledInHierarchy, lang + "precondition: the popup is usable");
+
+ rig.Advisor.Watch(Row, "advisor.x");
+ Assert.IsTrue(rig.HudRoot.ClassListContains("advisor-overlay-open"), lang + "precondition: the overlay is open");
+ Assert.IsFalse(popup.enabledInHierarchy, lang + "the popup is out of reach while the overlay is open");
+ Assert.IsFalse(gotIt.enabledInHierarchy, lang + "so are its buttons");
+ Assert.IsTrue(rig.Ui.Q<Button>("advisor-overlay-close").enabledInHierarchy, lang + "the overlay's own X stays reachable");
+
+ rig.Ui.Press("advisor-overlay-close");
+ Assert.IsTrue(popup.enabledInHierarchy && gotIt.enabledInHierarchy, lang + "closing the overlay gives the popup back");
+ }
+ }
+
[Test]
public void ConstructionDoesNotFetchOrPlay()
{