Show the current choice, keyboard focus, and states apart

Phase 5-5.

- The current radio row shows a check mark in the icon column and no
  fill (UI-051, replaces the radio rule of UI-003). The list of all
  tabs names pinned tabs in text.
- Keyboard focus adds a 2-pixel ring inside menu rows. The global
  focus ring is 2 pixels with a 1-pixel offset.
- Active toggles get the accent color, the selection fill, and a
  2-pixel accent bar. Hover gets only a neutral fill. Enabled icon
  buttons use --rs-text.
- Disabled controls use --rs-text-dim at full opacity, not opacity.
- The file tree has one Tab stop. Up and Down move, Shift extends the
  selection, Right opens or enters a folder, Left closes it or goes to
  its parent, Home and End go to the ends, and typed letters find a
  row.
- The three workbench splitters take focus. The arrow keys move them
  by 16 pixels, and Home and End go to their limits.
- Help names Esc, then Tab, to leave the text.
- 5 new catalog rows in French, Japanese, and Simplified Chinese.
- Docs: UI-051, ui-design.md, and the user guide.

Tests: the new layout/keyboardFocus. backgroundImages now expects the
check mark on the current radio row.
This commit is contained in:
Knotty Wyvern
2026-10-28 20:44:35 -07:00
parent c8cf56b224
commit b7a9784f55
19 changed files with 322 additions and 23 deletions
+54 -1
View File
@@ -217,6 +217,56 @@
selection = { paths: new Set([rel]), anchor: rel };
}
// The tree has one Tab stop: the last focused row, else the selection, the open file, or the first row.
let focusRel = $state<string | null>(null);
const tabStop = $derived([focusRel, selection.anchor, activePath].find(path => path && visiblePaths.includes(path)) ?? visiblePaths[0] ?? null);
let typed = "", typedAt = 0;
async function focusRow(rel: string) {
focusRel = rel;
await tick();
const row = [...treeElement.querySelectorAll<HTMLElement>("[data-tree-rel]")].find(node => node.dataset.treeRel === rel);
row?.focus({ preventScroll: true });
row?.scrollIntoView({ block: "nearest" });
}
// The keys of the tree pattern: arrows move, Right opens or enters a folder, Left closes it or goes to its parent,
// Home and End go to the ends, and typed letters find a row. Shift with an arrow extends the selection.
function treeKey(event: KeyboardEvent) {
const row = event.target instanceof HTMLElement && event.target.matches("[data-tree-rel]") ? event.target : null;
if (!row || event.ctrlKey || event.metaKey || event.altKey) return;
const rel = row.dataset.treeRel!;
const entry = findEntry(rel);
const index = visiblePaths.indexOf(rel);
if (!entry || index < 0) return;
let next: string | undefined;
if (event.key === "ArrowDown") next = visiblePaths[index + 1];
else if (event.key === "ArrowUp") next = visiblePaths[index - 1];
else if (event.key === "Home") next = visiblePaths[0];
else if (event.key === "End") next = visiblePaths.at(-1);
else if (event.key === "ArrowRight") {
if (entry.kind !== "folder") return;
event.preventDefault();
if (!expanded.has(rel)) toggleFolder(entry);
else if (childrenMap[rel]?.length) next = childrenMap[rel][0].rel_path;
} else if (event.key === "ArrowLeft") {
event.preventDefault();
if (entry.kind === "folder" && expanded.has(rel)) toggleFolder(entry);
else if (rel.includes("/")) next = parentRel(rel);
} else if (event.key.length === 1 && event.key !== " ") {
const now = Date.now();
typed = (now - typedAt < 700 ? typed : "") + event.key.toLowerCase();
typedAt = now;
const order = [...visiblePaths.slice(index + (typed.length === 1 ? 1 : 0)), ...visiblePaths.slice(0, index + (typed.length === 1 ? 1 : 0))];
next = order.find(path => (path.split("/").pop() ?? path).toLowerCase().startsWith(typed));
if (!next) return;
} else return;
event.preventDefault();
if (!next) return;
selection = event.shiftKey && event.key.startsWith("Arrow") ? selectTreePath(selection, next, visiblePaths, { shiftKey: true }) : { paths: new Set([next]), anchor: next };
void focusRow(next);
}
function onRowClick(entry: TreeEntry, modifiers: SelectionModifiers = {}, newTab = false) {
if (skipClick) {
skipClick = false;
@@ -945,7 +995,8 @@
<p class="muted">{$t("Loading…")}</p>
{/if}
{#if childrenMap[""]}
<ul role="tree" aria-label={$t("Workspace files")} aria-multiselectable="true">
<!-- svelte-ignore a11y_no_noninteractive_element_interactions (The tree handles the keys of its rows.) -->
<ul role="tree" aria-label={$t("Workspace files")} aria-multiselectable="true" onkeydown={treeKey}>
{#each childrenMap[""] as entry (entry.rel_path)}
<TreeNode
{entry}
@@ -969,6 +1020,8 @@
onRenameCommit={() => void commitRename()}
onRenameCancel={cancelRename}
{onDragPointerDown}
{tabStop}
onFocusRow={(rel) => (focusRel = rel)}
/>
{/each}
</ul>