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.

a11y: no scroll bar takes a Tab stop, not only the Cabinet's (Refs #41) (#1496)

EllaSharakanskifae34d41016f
diff --git a/changelog.d/a11y-all-scroll-bars-41.md b/changelog.d/a11y-all-scroll-bars-41.md
new file mode 100644
index 000000000..a523ba94f
--- /dev/null
+++ b/changelog.d/a11y-all-scroll-bars-41.md
@@ -0,0 +1,8 @@
+### Fixed
+
+- Keyboard: a scroll bar no longer takes a Tab stop, in any screen rather than only the Cabinet. A scroll view hides
+ its bar while its content fits, so the stray stop came back as soon as a list overflowed: in a short window the
+ Budget's bar and the Defence body's each took one, and any list can overflow with enough content or in a short
+ window. The turn report, the end screen and the capture dialog keep their bar, because it is the only way to scroll
+ them from the keyboard. Dragging the bar and the mouse wheel are unchanged, and PageUp, PageDown, Home and End
+ still scroll the open screen.
diff --git a/docs/accessibility-audit-2026-10-14.md b/docs/accessibility-audit-2026-10-14.md
index 071fa48ea..c0437b55c 100644
--- a/docs/accessibility-audit-2026-10-14.md
+++ b/docs/accessibility-audit-2026-10-14.md
@@ -410,14 +410,60 @@ EditMode test that fails without it.
| K5 | Opening a screen from the side rail leaves the focus on the rail button. A screen's content sits after the whole HUD in the Tab order, so reaching it means walking the rail's eight buttons, New Game, End Turn, the minimap's three buttons and star, report and share first. Walked in EditMode: 16 Tabs for the Cabinet and the Budget, 14 for Defence, the count being only where the player's button sits in the rail. `ScreenNav.Close` already hands the focus back to the rail button, so open was the asymmetric half. | `ScreenNav.Open` hands the focus to the screen it opened, after the screen's `OnOpened` action has built its rows. The screen's own X is first in its order, since the header is its first child, so the focus goes to the first control of the screen's content and the X stays one Shift+Tab back; a screen with no control of its own that can take the focus (Defence at the opening turn, whose ladder and call-up buttons are `display:none`) takes its X. Only a keyboard press hands the focus on, as `Close` already respects, so a mouse press still moves no focus. |
A scroll bar is never the landing control: `defence-body`'s scroller otherwise comes before any control of Defence's
-own. The bars of the screens other than the Cabinet take no Tab stop today, because a scroll view hides its scroller
-while the content fits, but their sliders stay focusable, so a bar becomes a stop once its list overflows. That is
-K3's scope and is not changed here.
+own. When K5 landed, the bars of the screens other than the Cabinet took no Tab stop but their sliders were still
+focusable, so one would have become a stop as soon as its list overflowed. K6 below closes that: every bar is out of
+the Tab order now.
Pinned in EditMode: `ScreenEntryTests` (the Cabinet and the Budget land on their first control; Defence, which has
none usable yet, lands on its X; a pointer press hands no focus; Escape still returns it to the rail button). No UI
string was added, so nothing goes to #564.
+## Every scroll bar out of the Tab order, 23 October 2026
+
+K3 again, wider. #1453 took the Cabinet's two views out of the Tab order, which is where the 23 October list found
+the stop. That was the whole of the finding as written, but not the whole of the bug: every other view's slider
+stayed `focusable`, and a `ScrollView` hides its scroller only while its content fits, so the stop returns the
+moment a view overflows.
+
+Walked in EditMode. At 1280x720, the opening turn, no screen stops on a bar, because every scroller but the seat
+list's is `display:none`:
+
+| screen | bar stops in one lap | scroller shown | slider focusable |
+|---|---|---|---|
+| cabinet (`cabinet-seats`) | 0 | yes | no, #1453 |
+| budget (`budget-rows`) | 0 | no | **yes** |
+| defence (`defence-body`) | 0 | no | **yes** |
+| why (`why-rows`) | 0 | no | **yes** |
+| timeline (`timeline-list`) | 0 | no | **yes** |
+| how to play (`how-to-play-body`) | 0 | no | **yes** |
+| objectives (`objectives-rows`) | 0 | no | **yes** |
+
+At 1280x420, the short window this audit already used a pass at, the views overflow and the stops are real:
+the Budget's bar and Defence's each take **one**, and the Cabinet still takes none. Defence is the worst case,
+since it has no control of its own at the opening turn, so its bar is very nearly all a keyboard player can land
+on. (An earlier draft of this section said Defence took two. That was the walk counting the same slider twice on
+two laps of a short screen, not two bars; the walk counts unique elements now.)
+
+| | Finding | Fix |
+|---|---|---|
+| K6 | Only the Cabinet's bars were out of the Tab order. Every other scroll view's slider was still focusable, so the stop came back whenever the view overflowed: a shorter window, or enough content in the list. `event-scroll`, `capture-scroll`, `turn-report-rows` and `end-screen-rows` are not on any screen's walk and were never checked at all. | `FocusScroll.NoScrollBarIsATabStop` applies the existing `BarsAreNotTabStops` to every `ScrollView` under the UI root, called once from `GameRoot` beside `FocusScroll`. `CabinetPresenter` keeps its own call, because many tests build that presenter without `GameRoot` and the Cabinet should not depend on the harness. |
+
+The reasoning is K3's, not wider: a bar is always in sight, a list is reached by Tabbing its rows, and the lists
+that hold labels only (`why-rows`, `defence-body`, the event card's text) have nothing to Tab to, while `KeyScroll`
+gives PageUp, PageDown, Home and End with or without focus. Focusability only: dragging and the wheel are untouched.
+
+Three views are left out of the sweep, because for them that reasoning does not hold: `turn-report-rows`,
+`end-screen-rows` and `capture-scroll`. `KeyScroll` has no target for any of them, `GameRoot` switches the paging
+keys off entirely while the turn report or the end screen is open, and their rows are plain labels, so Tab reaches
+nothing inside them. Taking their bar out would leave no keyboard route at all, which is worse than a stray stop.
+Giving `KeyScroll` a route to them is the better answer and is its own change.
+
+Pinned in EditMode: `ScrollBarTabStopTests` (in a 1280x420 window the Budget's and Defence's bars take no stop,
+with the overflow asserted as a precondition so the test cannot pass vacuously; the Cabinet stays at zero; no
+`ScrollView` in the tree keeps a focusable scroller, slider or arrow button apart from the three above; and those
+three do keep theirs, so the exclusion cannot be dropped by accident). No UI string was added, so nothing goes
+to #564.
+
## Screenshots
In `.superpowers/a11y-2026-10-14/` (1568x752 unless noted), with the driver and the contrast, colour-vision and
diff --git a/unity/Assets/Scripts/UI/FocusScroll.cs b/unity/Assets/Scripts/UI/FocusScroll.cs
index da9267403..5136488c2 100644
--- a/unity/Assets/Scripts/UI/FocusScroll.cs
+++ b/unity/Assets/Scripts/UI/FocusScroll.cs
@@ -87,6 +87,35 @@ namespace Statecraft.Game.UI
static bool LaidOut(Rect r) => !float.IsNaN(r.width) && !float.IsNaN(r.height) && r.width > 0f && r.height > 0f;
+ /// <summary>The views whose bar is the only way a keyboard player can scroll them, so it stays in the Tab
+ /// order. `KeyScroll` gives PageUp, PageDown, Home and End to the open screen's main view and to the decision
+ /// card's text, but it has no target for these three (`KeyScroll.MainViews`), and `GameRoot` turns those keys
+ /// off entirely while the turn report or the end screen is open (`GameRoot`, the `report?.IsOpen != true &&
+ /// end?.IsOpen != true` guard). Their rows are plain labels, so Tab reaches nothing inside them either. Taking
+ /// their bar out would leave no way at all to scroll them once they overflow, which is worse than the stray
+ /// stop. Giving `KeyScroll` a route to these is the better answer and is its own change; until then they stay
+ /// out of the sweep (#41 K6, the owner's review).</summary>
+ static readonly string[] OnlyReachableByTheirBar = { "turn-report-rows", "end-screen-rows", "capture-scroll" };
+
+ /// <summary>Takes every scroll bar under <paramref name="root"/> out of the Tab order (accessibility audit, #41,
+ /// K3 widened), except the few in <see cref="OnlyReachableByTheirBar"/>. #1453 did the Cabinet's two views,
+ /// which is where the audit found the stop: the seat list is the one long enough to show its bar in a 1280x720
+ /// window. Every other view's slider stayed focusable, and a ScrollView hides its scroller only while the
+ /// content fits, so the stop came back as soon as a view overflowed: a shorter window, or enough content.
+ /// Measured at 1280x420, the Budget's bar and Defence's each took a Tab stop, and Defence has no control of its
+ /// own at the opening turn, so its bar was very nearly all a keyboard player could land on.
+ ///
+ /// The same reasoning as K3, no wider: a bar is always in sight and a list is reached by Tabbing its rows, and
+ /// for the lists that hold labels only (why-rows, defence-body, the event card's text) there is nothing to Tab
+ /// to at all, while KeyScroll already gives PageUp, PageDown, Home and End with or without focus. Dragging the
+ /// bar and the wheel are untouched: this changes focusability, not behaviour.</summary>
+ public static void NoScrollBarIsATabStop(VisualElement root)
+ {
+ foreach (var view in root.Query<ScrollView>().Build())
+ if (System.Array.IndexOf(OnlyReachableByTheirBar, view.name) < 0)
+ BarsAreNotTabStops(view);
+ }
+
/// <summary>Takes a scroll view's own scroll bars out of the Tab order (accessibility audit, #41, the keyboard-only
/// turn's "Still open" list). A scroll bar is always in sight and the list it belongs to is reached by Tabbing
/// through its rows, so a stop on the bar only adds a press between the last row and the next control. Dragging it
diff --git a/unity/Assets/Scripts/UI/GameRoot.cs b/unity/Assets/Scripts/UI/GameRoot.cs
index b074b9cd0..2ef696b01 100644
--- a/unity/Assets/Scripts/UI/GameRoot.cs
+++ b/unity/Assets/Scripts/UI/GameRoot.cs
@@ -248,6 +248,7 @@ namespace Statecraft.Game.UI
nav = Own(new ScreenNav(root)); // every screen starts hidden (USS); ScreenNav opens one at a time
Own(new PointerBlur(root)); // a mouse click leaves no focus fill behind (keyboard keeps it)
Own(new FocusScroll(root)); // keyboard focus scrolls its ScrollView to it (a11y H1)
+ FocusScroll.NoScrollBarIsATabStop(root); // no scroll bar takes a Tab stop (#41 K3, widened from the Cabinet's two)
Own(new NavigationGuard(root)); // the camera keys (WASD, arrows) never move UI focus (B6)
if (DiagLog.Nav) Own(new NavEventLog(root)); // ?navlog: every UI pointer/submit event (playtest 2, P2-4)
// The Illustration switch's silent loops (event-videos.yaml, Resources): none in the automated runs (CardVideo.ForcedOff).
diff --git a/unity/Assets/Scripts/UI/ScreenNav.cs b/unity/Assets/Scripts/UI/ScreenNav.cs
index 95eb28fb0..8ac4a87c6 100644
--- a/unity/Assets/Scripts/UI/ScreenNav.cs
+++ b/unity/Assets/Scripts/UI/ScreenNav.cs
@@ -329,9 +329,9 @@ namespace Statecraft.Game.UI
{
if (e == screen || e == x || !FocusReturn.CanTakeFocus(e)) continue;
// Not a scroll bar: Defence's defence-body puts its scroller before any control of its own, and a bar is
- // no use from the keyboard (#41 K3, which took the Cabinet's bars out of the Tab order). The other
- // screens' bars take no stop today, since a view hides its scroller while the content fits, but their
- // sliders stay focusable, so one becomes a stop once its list overflows; that is K3's scope, not this one's.
+ // no use from the keyboard (#41 K3, which took the Cabinet's bars out of the Tab order, and K6, which
+ // took every other one out too). The skip stays: it is what keeps the landing control a real control
+ // even while a bar is on screen.
if (e is Scroller || e.GetFirstAncestorOfType<Scroller>() != null) continue;
first = e;
break;
diff --git a/unity/Assets/Tests/EditMode/ScrollBarShots.cs b/unity/Assets/Tests/EditMode/ScrollBarShots.cs
new file mode 100644
index 000000000..ef4d72156
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/ScrollBarShots.cs
@@ -0,0 +1,154 @@
+#nullable enable
+using System;
+using System.Collections;
+using System.IO;
+using NUnit.Framework;
+using Statecraft.Game;
+using Statecraft.Game.Map;
+using Statecraft.Game.UI;
+using UnityEditor.SceneManagement;
+using UnityEngine;
+using UnityEngine.TestTools;
+using UnityEngine.UIElements;
+using Object = UnityEngine.Object;
+
+/// <summary>Writes the before and after stills for #41 K6, in English and Hebrew, to `.superpowers/a11y-bars-41/`
+/// (local, not committed). A 1280x420 window, so the Budget's rows overflow and its bar is shown and in the order.
+/// The "before" state puts the bar's slider back in the Tab order, which is what it was before the change, and Tabs
+/// from the Budget's rail button until the bar takes the focus; the "after" state walks the same number of presses
+/// from the same start. Explicit, so it does not run with the
+/// checks.</summary>
+[Explicit("writes stills for a pull request, not a check")]
+public class ScrollBarShots
+{
+ string saveDir = "";
+ string shotDir = "";
+ RenderTexture? rt; PanelSettings? ps;
+ VisualElement ui = null!;
+ GameRoot root = null!;
+
+ [SetUp]
+ public void TempSaves()
+ {
+ saveDir = Path.Combine(Path.GetTempPath(), "statecraft-bars-" + Guid.NewGuid().ToString("N"));
+ shotDir = Path.Combine(Directory.GetCurrentDirectory(), ".superpowers", "a11y-bars-41");
+ Directory.CreateDirectory(shotDir);
+ }
+
+ [TearDown]
+ public void DiscardScene()
+ {
+ EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);
+ if (ps != null) Object.DestroyImmediate(ps);
+ if (rt != null) { rt.Release(); Object.DestroyImmediate(rt); }
+ if (Directory.Exists(saveDir)) Directory.Delete(saveDir, true);
+ }
+
+ Focusable? Focused => ui.panel?.focusController?.focusedElement;
+ VisualElement At => Focused as VisualElement ?? throw new AssertionException("nothing has the focus");
+ string FocusedName => (Focused as VisualElement)?.name is string n && n.Length > 0 ? n : Focused == null ? "none" : Focused.GetType().Name;
+ IEnumerator Frames(int n) { for (int i = 0; i < n; i++) yield return null; }
+
+ IEnumerator Tab()
+ {
+ var at = At;
+ using (var e = NavigationMoveEvent.GetPooled(NavigationMoveEvent.Direction.Next)) { e.target = at; at.SendEvent(e); }
+ yield return null;
+ }
+
+ IEnumerator Enter()
+ {
+ var at = At;
+ using (var s = NavigationSubmitEvent.GetPooled()) { s.target = at; at.SendEvent(s); }
+ yield return null;
+ }
+
+ IEnumerator Boot(bool hebrew)
+ {
+ EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);
+ var doc = Object.FindFirstObjectByType<UIDocument>();
+ rt = new RenderTexture(1280, 420, 24);
+ ps = Object.Instantiate(doc.panelSettings);
+ ps.targetTexture = rt;
+ doc.panelSettings = ps;
+ Object.FindFirstObjectByType<MapScene>().Build(MapFocusTests.Inputs.Map);
+ root = Object.FindFirstObjectByType<GameRoot>();
+ root.Store = new SaveStore(saveDir);
+ if (hebrew) root.Language = UiLanguage.Hebrew;
+ root.Begin(MapFocusTests.Inputs, 0);
+ ui = doc.rootVisualElement;
+ for (int i = 0; i < 30 && !(ui.Q("top-bar").worldBound.height > 0); i++) yield return null;
+ yield return Frames(5);
+ GameSceneTests.HideTheOpeningCard(ui);
+ yield return Frames(3);
+ }
+
+ void Shot(string name)
+ {
+ var prev = RenderTexture.active;
+ RenderTexture.active = rt;
+ var tex = new Texture2D(rt!.width, rt.height, TextureFormat.RGB24, false);
+ tex.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0);
+ tex.Apply();
+ RenderTexture.active = prev;
+ File.WriteAllBytes(Path.Combine(shotDir, name + ".png"), tex.EncodeToPNG());
+ Object.DestroyImmediate(tex);
+ Debug.Log($"SHOT {name}: focus is on {FocusedName}");
+ }
+
+ static void PutTheBarBackInTheOrder(ScrollView v)
+ {
+ var s = v.verticalScroller;
+ s.focusable = true;
+ if (s.slider != null) s.slider.focusable = true;
+ }
+
+ /// <summary>Tabs up to <paramref name="max"/> times, stopping early on a scroll bar. Returns the number of
+ /// presses made, so the other state can be walked the same number from the same start: a fair pair.</summary>
+ IEnumerator TabToTheBar(int[] steps, int max = 60)
+ {
+ steps[0] = 0;
+ for (int i = 0; i < max; i++)
+ {
+ yield return Tab();
+ steps[0]++;
+ if (Focused is VisualElement at && (at is Scroller || at.GetFirstAncestorOfType<Scroller>() != null)) yield break;
+ }
+ }
+
+ IEnumerator TabExactly(int n)
+ {
+ for (int i = 0; i < n; i++) yield return Tab();
+ }
+
+ IEnumerator Shots(bool hebrew)
+ {
+ var lang = hebrew ? "he" : "en";
+ yield return Boot(hebrew);
+
+ ui.Q<Button>("nav-budget").Focus();
+ yield return null;
+ yield return Enter();
+ yield return Frames(5);
+
+ var rows = ui.Q<ScrollView>("budget-rows");
+ Debug.Log($"BARSHOT {lang}: budget-rows content={rows.contentContainer.layout.height:F0} viewport={rows.contentViewport.layout.height:F0}");
+
+ // before: the slider back in the order, exactly as it was before this change; Tab until the bar takes the focus
+ PutTheBarBackInTheOrder(rows);
+ ui.Q<Button>("nav-budget").Focus(); yield return null;
+ var steps = new int[1];
+ yield return TabToTheBar(steps);
+ Debug.Log($"BARSHOT {lang}: the bar takes the focus after {steps[0]} presses, on {FocusedName}");
+ Shot($"budget-before-{lang}");
+
+ // after: the bar out of the order again, the same number of presses from the same start
+ FocusScroll.BarsAreNotTabStops(rows);
+ ui.Q<Button>("nav-budget").Focus(); yield return null;
+ yield return TabExactly(steps[0]);
+ Shot($"budget-after-{lang}");
+ }
+
+ [UnityTest] public IEnumerator English() { yield return Shots(false); }
+ [UnityTest] public IEnumerator Hebrew() { yield return Shots(true); }
+}
diff --git a/unity/Assets/Tests/EditMode/ScrollBarShots.cs.meta b/unity/Assets/Tests/EditMode/ScrollBarShots.cs.meta
new file mode 100644
index 000000000..9a67d2edd
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/ScrollBarShots.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: a4ad18bf3457f4540afc2ef1083346f5
\ No newline at end of file
diff --git a/unity/Assets/Tests/EditMode/ScrollBarTabStopTests.cs b/unity/Assets/Tests/EditMode/ScrollBarTabStopTests.cs
new file mode 100644
index 000000000..93ce73cb6
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/ScrollBarTabStopTests.cs
@@ -0,0 +1,184 @@
+#nullable enable
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using NUnit.Framework;
+using Statecraft.Game;
+using Statecraft.Game.Map;
+using Statecraft.Game.UI;
+using UnityEditor.SceneManagement;
+using UnityEngine;
+using UnityEngine.TestTools;
+using UnityEngine.UIElements;
+using Object = UnityEngine.Object;
+
+/// <summary>#41 K3, widened: a scroll bar is no use from the keyboard, so none of them should take a Tab stop. #1453
+/// took the Cabinet's two out of the order, which is where the audit found the stop, because the seat list is the one
+/// long enough to show its bar in a 1280x720 window. Every other view's slider stayed focusable, and a ScrollView hides
+/// its scroller only while the content fits, so the stop comes back as soon as a view overflows: a shorter window, or
+/// enough content in the list.
+///
+/// These run in a 1280x420 window, the short window the 14 October audit also used, so the Budget's and Defence's
+/// views overflow and their bars are really in the order. Defence is the worst case: it has no control of its own at
+/// the opening turn, so its bar is very nearly the only thing a keyboard player can land on.
+///
+/// `turn-report-rows`, `end-screen-rows` and `capture-scroll` are deliberately not swept: their bar is the only way a
+/// keyboard player can scroll them, and that exclusion is pinned below so it cannot be dropped by accident.</summary>
+public class ScrollBarTabStopTests
+{
+ string saveDir = "";
+ RenderTexture? rt; PanelSettings? ps;
+ VisualElement ui = null!;
+ GameRoot root = null!;
+
+ [SetUp] public void TempSaves() => saveDir = Path.Combine(Path.GetTempPath(), "statecraft-bars-" + Guid.NewGuid().ToString("N"));
+
+ [TearDown]
+ public void DiscardScene()
+ {
+ EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);
+ if (ps != null) Object.DestroyImmediate(ps);
+ if (rt != null) { rt.Release(); Object.DestroyImmediate(rt); }
+ if (Directory.Exists(saveDir)) Directory.Delete(saveDir, true);
+ }
+
+ Focusable? Focused => ui.panel?.focusController?.focusedElement;
+ VisualElement At => Focused as VisualElement ?? throw new AssertionException("nothing has the focus");
+ string FocusedName => (Focused as VisualElement)?.name is string n && n.Length > 0 ? n : Focused == null ? "none" : Focused.GetType().Name;
+ IEnumerator Frames(int n) { for (int i = 0; i < n; i++) yield return null; }
+
+ IEnumerator Tab()
+ {
+ var at = At;
+ using (var e = NavigationMoveEvent.GetPooled(NavigationMoveEvent.Direction.Next)) { e.target = at; at.SendEvent(e); }
+ yield return null;
+ }
+
+ IEnumerator Enter()
+ {
+ var at = At;
+ using (var s = NavigationSubmitEvent.GetPooled()) { s.target = at; at.SendEvent(s); }
+ yield return null;
+ }
+
+ /// <summary>A 1280x420 window: short enough that the Budget's and Defence's views overflow and show their bars.</summary>
+ IEnumerator BootShort()
+ {
+ EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);
+ var doc = Object.FindFirstObjectByType<UIDocument>();
+ rt = new RenderTexture(1280, 420, 0);
+ ps = Object.Instantiate(doc.panelSettings);
+ ps.targetTexture = rt;
+ doc.panelSettings = ps;
+ Object.FindFirstObjectByType<MapScene>().Build(MapFocusTests.Inputs.Map);
+ root = Object.FindFirstObjectByType<GameRoot>();
+ root.Store = new SaveStore(saveDir);
+ root.Begin(MapFocusTests.Inputs, 0);
+ ui = doc.rootVisualElement;
+ for (int i = 0; i < 30 && !(ui.Q("top-bar").worldBound.height > 0); i++) yield return null;
+ yield return Frames(5);
+ GameSceneTests.HideTheOpeningCard(ui);
+ yield return Frames(3);
+ }
+
+ static bool IsBar(VisualElement e) => e is Scroller || e.GetFirstAncestorOfType<Scroller>() != null;
+
+ /// <summary>Opens the screen from its rail button, presses Tab 45 times and returns the scroll views whose bar took
+ /// a stop inside that screen. 45 is comfortably more than a lap of the HUD and any one screen today; it is a fixed
+ /// count rather than "until the focus comes back", so a screen that grows past it would under-report rather than
+ /// loop.</summary>
+ IEnumerator BarStops(string screen, List<string> found)
+ {
+ var nav = ui.Q<Button>("nav-" + screen);
+ Assert.IsNotNull(nav, $"precondition: the rail has a button for {screen}");
+ nav.Focus();
+ yield return null;
+ yield return Enter();
+ yield return Frames(5);
+ var panel = ui.Q<VisualElement>("screen-" + screen);
+ // Unique elements, not every hit: 45 presses is more than one lap on a short screen, so the same bar comes
+ // round again and counting hits would overstate it (the owner's review of 3923ce06).
+ var seen = new HashSet<VisualElement>();
+ for (int i = 0; i < 45; i++)
+ {
+ yield return Tab();
+ if (Focused is VisualElement at && IsBar(at) && panel != null && panel.Contains(at) && seen.Add(at))
+ found.Add(at.GetFirstAncestorOfType<ScrollView>()?.name ?? "?");
+ }
+ }
+
+ [UnityTest]
+ [TestCase("budget", "budget-rows", ExpectedResult = null)]
+ [TestCase("defence", "defence-body", ExpectedResult = null)]
+ public IEnumerator AnOverflowingScreensScrollBarIsNotATabStop(string screen, string view)
+ {
+ yield return BootShort();
+
+ var found = new List<string>();
+ yield return BarStops(screen, found);
+
+ // precondition: the view really does overflow here, so its bar is shown and this test means something
+ var sv = ui.Q<ScrollView>(view);
+ Assert.IsNotNull(sv, $"precondition: {view} is in the tree");
+ Assert.Greater(sv.contentContainer.layout.height, sv.contentViewport.layout.height + 0.5f,
+ $"precondition: {view} overflows in a 1280x420 window, so its bar is shown");
+ Assert.AreEqual(DisplayStyle.Flex, sv.verticalScroller.resolvedStyle.display,
+ $"precondition: {view}'s scroller is shown");
+
+ Assert.IsEmpty(found, $"no scroll bar takes a Tab stop in {screen}, but one lap stopped on: {string.Join(", ", found)}");
+ }
+
+ /// <summary>The Cabinet, which #1453 already fixed, stays at zero in the short window too.</summary>
+ [UnityTest]
+ public IEnumerator TheCabinetStaysFreeOfBarStopsInAShortWindow()
+ {
+ yield return BootShort();
+ var found = new List<string>();
+ yield return BarStops("cabinet", found);
+ Assert.IsEmpty(found, $"the Cabinet's bars stay out of the order, but one lap stopped on: {string.Join(", ", found)}");
+ }
+
+ /// <summary>Every ScrollView in the tree has both of its bars out of the order, except the three whose bar is the
+ /// only way a keyboard player can scroll them. `KeyScroll` has no target for `turn-report-rows`,
+ /// `end-screen-rows` or `capture-scroll`, and `GameRoot` switches PageUp, PageDown, Home and End off entirely
+ /// while the report or the end screen is open, so taking their bar out would leave no keyboard route at all.</summary>
+ [UnityTest]
+ public IEnumerator NoScrollViewInTheTreeKeepsAFocusableBar()
+ {
+ yield return BootShort();
+ var exempt = new[] { "turn-report-rows", "end-screen-rows", "capture-scroll" };
+ var bad = new List<string>();
+ foreach (var sv in ui.Query<ScrollView>().Build())
+ {
+ if (System.Array.IndexOf(exempt, sv.name) >= 0) continue;
+ // both bars, as the helper itself sets: "every scroll bar" means the horizontal one too
+ foreach (var (which, s) in new[] { ("vertical", sv.verticalScroller), ("horizontal", sv.horizontalScroller) })
+ {
+ if (s == null) continue;
+ var at = $"{sv.name}.{which}";
+ if (s.focusable) bad.Add(at + ".scroller");
+ if (s.slider != null && s.slider.focusable) bad.Add(at + ".slider");
+ if (s.lowButton != null && s.lowButton.focusable) bad.Add(at + ".lowButton");
+ if (s.highButton != null && s.highButton.focusable) bad.Add(at + ".highButton");
+ }
+ }
+ Assert.IsEmpty(bad, $"these scroll bars can still take the focus: {string.Join(", ", bad)}");
+ }
+
+ /// <summary>The exclusion is deliberate, so it is pinned: the three views the keyboard cannot otherwise scroll
+ /// keep a focusable bar. If `KeyScroll` is ever given a route to them, this test should be deleted along with the
+ /// exclusion in `FocusScroll.OnlyReachableByTheirBar` (#41 K6, the owner's review).</summary>
+ [UnityTest]
+ public IEnumerator TheViewsTheKeyboardCannotOtherwiseScrollKeepTheirBar()
+ {
+ yield return BootShort();
+ foreach (var name in new[] { "turn-report-rows", "end-screen-rows", "capture-scroll" })
+ {
+ var sv = ui.Q<ScrollView>(name);
+ Assert.IsNotNull(sv, $"precondition: {name} is in the tree");
+ Assert.IsTrue(sv.verticalScroller.slider.focusable,
+ $"{name} has no keyboard scroll route but its bar, so the bar stays reachable");
+ }
+ }
+}
diff --git a/unity/Assets/Tests/EditMode/ScrollBarTabStopTests.cs.meta b/unity/Assets/Tests/EditMode/ScrollBarTabStopTests.cs.meta
new file mode 100644
index 000000000..01b4c1e69
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/ScrollBarTabStopTests.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 6b5a331d2712d41ccbd896c7c3ed11d0
\ No newline at end of file