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:
@@ -950,3 +950,18 @@ Native shell, background image, and desktop acceptance remain open.
|
|||||||
- Evidence: `tests/smoke/layout/titleBar.smoke.mjs` and the Rust command list test.
|
- Evidence: `tests/smoke/layout/titleBar.smoke.mjs` and the Rust command list test.
|
||||||
- Replaces / replaced by: The left pane footer, and the ribbon rule "The ribbon has no width when it has no entries."
|
- Replaces / replaced by: The left pane footer, and the ribbon rule "The ribbon has no width when it has no entries."
|
||||||
- Limits: Browser checks use desktop service mocks. Snap Layouts, the native drag area, and the macOS title bar need native acceptance. The macOS code path was not compiled here. On Windows 10, Win+Z does nothing.
|
- Limits: Browser checks use desktop service mocks. Snap Layouts, the native drag area, and the macOS title bar need native acceptance. The macOS code path was not compiled here. On Windows 10, Win+Z does nothing.
|
||||||
|
|
||||||
|
### UI-051 — Check marks, focus rings, and control states
|
||||||
|
|
||||||
|
- Type: Rule change
|
||||||
|
- Date: 2026-10-28
|
||||||
|
- Status: Implemented for user review
|
||||||
|
- Decision source: Owner decisions 8 and 13 (keyboard and focus) of 2026-10-27 (interface review issues 4 and 14, and finding 2 on UI-003), stage 5-5.
|
||||||
|
- Previous rule: The current radio row had the hover fill and no check mark, so a hovered row and the current row looked the same. Hover and keyboard focus shared one fill. Hover and active toggles shared one look. Disabled controls faded to 40 to 50% opacity (2.46:1 in light). The focus ring was 1 pixel and inset. Every file tree row was a Tab stop, and the tree had no arrow keys. Splitters took no keyboard focus.
|
||||||
|
- New rule: The current radio row shows a check mark in the icon column and no fill. Keyboard focus adds a 2-pixel ring to the shared hover fill. Active toggles get the accent color, the selection fill, and a 2-pixel accent bar. Disabled controls use `--rs-text-dim` at full opacity, and enabled icon buttons use `--rs-text`. The global focus ring is 2 pixels with a 1-pixel offset. The file tree has one Tab stop, arrow keys, Home, End, and type-ahead. Splitters take focus and move by 16 pixels with the arrow keys. Help names Esc, then Tab, to leave the text.
|
||||||
|
- Reason: The current choice, the pointer, and the keyboard focus must each be visible on their own. Disabled text must stay readable.
|
||||||
|
- Scope: Shared menus and pickers, icon buttons, all disabled buttons, the file tree, and the workbench splitters.
|
||||||
|
- Shared implementation: `actionMenu.ts` (the check mark), `menu.css`, `base.css`, `IconButton.svelte`, `FileTree.svelte`, `TreeNode.svelte`, and `splitterKey` in `Workbench.svelte`.
|
||||||
|
- Evidence: `tests/smoke/layout/keyboardFocus.smoke.mjs`.
|
||||||
|
- Replaces / replaced by: The radio rule of [UI-003](#ui-003--quiet-menu-choices). Other parts of UI-003 remain.
|
||||||
|
- Limits: The check mark replaces the icon of a radio row. The list of all tabs names pinned tabs in text. Browser checks use desktop service mocks.
|
||||||
|
|||||||
+8
-3
@@ -70,6 +70,11 @@ Do not copy feature-specific colors into a shared control.
|
|||||||
|
|
||||||
- Controls, menu rows, and navigation highlights use `--rs-control-radius`. This includes hover, active, and selected states.
|
- Controls, menu rows, and navigation highlights use `--rs-control-radius`. This includes hover, active, and selected states.
|
||||||
- Keep readable labels, visible focus indicators, and comfortable click targets in compact layouts.
|
- Keep readable labels, visible focus indicators, and comfortable click targets in compact layouts.
|
||||||
|
- Keyboard focus shows a 2-pixel `--rs-focus` ring outside the control. Menu rows draw the ring inside the row. Hover never shows the ring.
|
||||||
|
- Hover gets a neutral fill. An active toggle also gets the accent color, the selection fill, and a 2-pixel accent bar, so it differs from hover.
|
||||||
|
- A disabled control uses `--rs-text-dim` at full opacity. Do not fade a control with opacity.
|
||||||
|
- A composite widget, such as the file tree, has one Tab stop. The arrow keys move inside it.
|
||||||
|
- A splitter takes keyboard focus. The arrow keys move it by 16 pixels, and Home and End go to its limits.
|
||||||
- Native form controls, such as checkboxes, take their accent from `--rs-accent`, not the browser default ([UI-030](design-decisions.md#ui-030--settings-installation-checkbox-theme-drift)).
|
- Native form controls, such as checkboxes, take their accent from `--rs-accent`, not the browser default ([UI-030](design-decisions.md#ui-030--settings-installation-checkbox-theme-drift)).
|
||||||
- Document tables are the exception. Keep their grid, cells, and cell selection outlines square. Table toolbars and table menus stay rounded.
|
- Document tables are the exception. Keep their grid, cells, and cell selection outlines square. Table toolbars and table menus stay rounded.
|
||||||
|
|
||||||
@@ -107,9 +112,9 @@ Use one menu design for context menus, action menus, and their submenus in the h
|
|||||||
- A common text action has the same label, icon, and shortcut in every menu. Build Undo, Redo, the clipboard rows, and the search row with `menuItems.ts`.
|
- A common text action has the same label, icon, and shortcut in every menu. Build Undo, Redo, the clipboard rows, and the search row with `menuItems.ts`.
|
||||||
- Write shortcut labels with `src/lib/ui/shortcuts.ts`: `keys("Mod+Shift+P")` gives Ctrl+Shift+P on Windows and Linux and ⇧⌘P on macOS. A workbench command takes its label from `commandShortcut()` in `workbenchKeys.ts`. Do not write "Ctrl" in interface text or in the catalog. Use a placeholder.
|
- Write shortcut labels with `src/lib/ui/shortcuts.ts`: `keys("Mod+Shift+P")` gives Ctrl+Shift+P on Windows and Linux and ⇧⌘P on macOS. A workbench command takes its label from `commandShortcut()` in `workbenchKeys.ts`. Do not write "Ctrl" in interface text or in the catalog. Use a placeholder.
|
||||||
- Use inset separators between related groups.
|
- Use inset separators between related groups.
|
||||||
- Enabled rows share one hover fill and one keyboard focus fill.
|
- Enabled rows share one hover fill. Keyboard focus adds a 2-pixel ring inside the row.
|
||||||
- Disabled rows stay readable. Keyboard navigation skips them, and they do not run.
|
- Disabled rows stay readable: dim text at full opacity. Keyboard navigation skips them, and they do not run.
|
||||||
- Radio choices mark the current option with the shared fill and no checkmark. The current enabled radio choice gets focus when the menu opens.
|
- Radio choices mark the current option with a check mark in the icon column, and no fill. The current enabled radio choice gets focus when the menu opens.
|
||||||
- A row can have a default action and a submenu. A click on the label, Enter, or Space runs the default action. Hover, the submenu arrow, or Right opens the submenu.
|
- A row can have a default action and a submenu. A click on the label, Enter, or Space runs the default action. Hover, the submenu arrow, or Right opens the submenu.
|
||||||
|
|
||||||
### Keyboard and viewport
|
### Keyboard and viewport
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ To show workspace settings and plugin data in the navigator, turn on **Settings
|
|||||||
|
|
||||||
Right-click a file or folder for more actions, such as **Make a copy**, **Copy workspace path**, and **Open in default app**.
|
Right-click a file or folder for more actions, such as **Make a copy**, **Copy workspace path**, and **Open in default app**.
|
||||||
With the navigator focused, Ctrl+X, Ctrl+C, and Ctrl+V cut, copy, and paste files.
|
With the navigator focused, Ctrl+X, Ctrl+C, and Ctrl+V cut, copy, and paste files.
|
||||||
|
The navigator is one Tab stop. Up and Down move between items, and Shift+Up or Shift+Down extends the selection. Right opens a folder or enters it. Left closes a folder or goes to its parent. Home and End go to the first and last item. Type the start of a name to go to it.
|
||||||
Ctrl+Z undoes a file move or rename, and Ctrl+Shift+Z or Ctrl+Y repeats it.
|
Ctrl+Z undoes a file move or rename, and Ctrl+Shift+Z or Ctrl+Y repeats it.
|
||||||
|
|
||||||
### Delete files
|
### Delete files
|
||||||
@@ -230,12 +231,14 @@ This table lists the Windows and Linux keys. On macOS, Cmd replaces Ctrl, and Ru
|
|||||||
| Switch Write and Source | Ctrl+E |
|
| Switch Write and Source | Ctrl+E |
|
||||||
| Switch Read and the editor | Ctrl+Shift+E |
|
| Switch Read and the editor | Ctrl+Shift+E |
|
||||||
| Nest a list item / Move it up | Tab / Shift+Tab |
|
| Nest a list item / Move it up | Tab / Shift+Tab |
|
||||||
|
| Leave the text, then move the focus on | Esc, then Tab |
|
||||||
| Bold / Italic / Link (Write) | Ctrl+B / Ctrl+I / Ctrl+K |
|
| Bold / Italic / Link (Write) | Ctrl+B / Ctrl+I / Ctrl+K |
|
||||||
| Strikethrough / Highlight (Write) | Ctrl+Shift+X / Ctrl+Shift+H |
|
| Strikethrough / Highlight (Write) | Ctrl+Shift+X / Ctrl+Shift+H |
|
||||||
| Show or hide the sidebar | Ctrl+\ |
|
| Show or hide the sidebar | Ctrl+\ |
|
||||||
| Rename | F2 |
|
| Rename | F2 |
|
||||||
| Delete to the trash / Delete permanently | Delete / Shift+Delete |
|
| Delete to the trash / Delete permanently | Delete / Shift+Delete |
|
||||||
| Context menu | Shift+F10 |
|
| Context menu | Shift+F10 |
|
||||||
|
| Resize a pane | Tab to its divider, then press the arrow keys |
|
||||||
| Settings / Help and about | Ctrl+, / F1 |
|
| Settings / Help and about | Ctrl+, / F1 |
|
||||||
|
|
||||||
The [Terminal guide](guides/terminal.md) lists the terminal shortcuts.
|
The [Terminal guide](guides/terminal.md) lists the terminal shortcuts.
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
.image-action { position: relative; display: inline-grid; place-items: center; flex: 0 0 34px; width: 34px; height: 34px; padding: 6px; color: var(--rs-text); border: 0; border-radius: 4px; background: transparent; cursor: pointer; }
|
.image-action { position: relative; display: inline-grid; place-items: center; flex: 0 0 34px; width: 34px; height: 34px; padding: 6px; color: var(--rs-text); border: 0; border-radius: 4px; background: transparent; cursor: pointer; }
|
||||||
.image-action:hover, .image-action:focus-visible { background: var(--rs-bg-active); color: var(--rs-text-strong); }
|
.image-action:hover, .image-action:focus-visible { background: var(--rs-bg-active); color: var(--rs-text-strong); }
|
||||||
.image-action:focus-visible { outline: 2px solid var(--rs-focus); outline-offset: 1px; }
|
.image-action:focus-visible { outline: 2px solid var(--rs-focus); outline-offset: 1px; }
|
||||||
.image-action:disabled { opacity: .4; cursor: default; }
|
.image-action:disabled { color: var(--rs-text-dim); cursor: default; }
|
||||||
.image-lightbox { position: fixed; inset: 0; width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: var(--rs-image-viewer-bg); color: var(--rs-text); }
|
.image-lightbox { position: fixed; inset: 0; width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: var(--rs-image-viewer-bg); color: var(--rs-text); }
|
||||||
.image-lightbox[open] { display: flex; flex-direction: column; }
|
.image-lightbox[open] { display: flex; flex-direction: column; }
|
||||||
.image-lightbox::backdrop { background: var(--rs-scrim); }
|
.image-lightbox::backdrop { background: var(--rs-scrim); }
|
||||||
|
|||||||
@@ -3461,6 +3461,11 @@ export const messageRows: [string, string, string, string][] = [
|
|||||||
["Unsaved", "Non enregistré", "未保存", "未保存"],
|
["Unsaved", "Non enregistré", "未保存", "未保存"],
|
||||||
["All tabs", "Tous les onglets", "すべてのタブ", "所有标签页"],
|
["All tabs", "Tous les onglets", "すべてのタブ", "所有标签页"],
|
||||||
["Open folder ({shortcut})", "Ouvrir un dossier ({shortcut})", "フォルダーを開く ({shortcut})", "打开文件夹 ({shortcut})"],
|
["Open folder ({shortcut})", "Ouvrir un dossier ({shortcut})", "フォルダーを開く ({shortcut})", "打开文件夹 ({shortcut})"],
|
||||||
|
["Pinned", "Épinglé", "ピン留め", "已固定"],
|
||||||
|
["Resize the side pane", "Redimensionner le panneau latéral", "サイドパネルのサイズを変更", "调整侧边面板大小"],
|
||||||
|
["Resize the outline", "Redimensionner le plan", "アウトラインのサイズを変更", "调整大纲大小"],
|
||||||
|
["Resize the terminal", "Redimensionner le terminal", "ターミナルのサイズを変更", "调整终端大小"],
|
||||||
|
["Leave the text, then press Tab", "Quitter le texte, puis appuyer sur Tab", "テキストから出て、Tab キーを押す", "离开文本,然后按 Tab"],
|
||||||
];
|
];
|
||||||
export const catalogs: Record<Exclude<Locale, 'en'>, Record<string, string>> = {
|
export const catalogs: Record<Exclude<Locale, 'en'>, Record<string, string>> = {
|
||||||
fr: Object.fromEntries(messageRows.map(row => [row[0], row[1]])),
|
fr: Object.fromEntries(messageRows.map(row => [row[0], row[1]])),
|
||||||
|
|||||||
@@ -217,6 +217,56 @@
|
|||||||
selection = { paths: new Set([rel]), anchor: rel };
|
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) {
|
function onRowClick(entry: TreeEntry, modifiers: SelectionModifiers = {}, newTab = false) {
|
||||||
if (skipClick) {
|
if (skipClick) {
|
||||||
skipClick = false;
|
skipClick = false;
|
||||||
@@ -945,7 +995,8 @@
|
|||||||
<p class="muted">{$t("Loading…")}</p>
|
<p class="muted">{$t("Loading…")}</p>
|
||||||
{/if}
|
{/if}
|
||||||
{#if childrenMap[""]}
|
{#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)}
|
{#each childrenMap[""] as entry (entry.rel_path)}
|
||||||
<TreeNode
|
<TreeNode
|
||||||
{entry}
|
{entry}
|
||||||
@@ -969,6 +1020,8 @@
|
|||||||
onRenameCommit={() => void commitRename()}
|
onRenameCommit={() => void commitRename()}
|
||||||
onRenameCancel={cancelRename}
|
onRenameCancel={cancelRename}
|
||||||
{onDragPointerDown}
|
{onDragPointerDown}
|
||||||
|
{tabStop}
|
||||||
|
onFocusRow={(rel) => (focusRel = rel)}
|
||||||
/>
|
/>
|
||||||
{/each}
|
{/each}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -235,7 +235,7 @@
|
|||||||
.switch:checked::before { transform: translateX(16px); background: var(--rs-bg); }
|
.switch:checked::before { transform: translateX(16px); background: var(--rs-bg); }
|
||||||
.interval { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; font-size: 11px; color: var(--rs-text-dim); }
|
.interval { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; font-size: 11px; color: var(--rs-text-dim); }
|
||||||
.interval input { width: 72px; min-height: var(--rs-settings-control-height); padding: 4px 6px; border: 1px solid var(--rs-border); border-radius: var(--rs-control-radius); background: var(--rs-bg); color: var(--rs-text); font-size: 13px; }
|
.interval input { width: 72px; min-height: var(--rs-settings-control-height); padding: 4px 6px; border: 1px solid var(--rs-border); border-radius: var(--rs-control-radius); background: var(--rs-bg); color: var(--rs-text); font-size: 13px; }
|
||||||
.interval input:disabled { opacity: .45; }
|
.interval input:disabled { color: var(--rs-text-dim); }
|
||||||
.note, .section-footer, .about-note { font-size: 12px; }
|
.note, .section-footer, .about-note { font-size: 12px; }
|
||||||
.note { margin: 10px 0 var(--rs-settings-section-gap); }
|
.note { margin: 10px 0 var(--rs-settings-section-gap); }
|
||||||
.section-footer { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; color: var(--rs-text-dim); }
|
.section-footer { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; color: var(--rs-text-dim); }
|
||||||
|
|||||||
@@ -176,8 +176,8 @@
|
|||||||
menuAnchor = allTabsButton;
|
menuAnchor = allTabsButton;
|
||||||
const bounds = allTabsButton!.getBoundingClientRect();
|
const bounds = allTabsButton!.getBoundingClientRect();
|
||||||
menu = actionMenu(bounds.left, bounds.bottom + 2, tabs.map(tab => ({
|
menu = actionMenu(bounds.left, bounds.bottom + 2, tabs.map(tab => ({
|
||||||
label: tab.name, radio: true, checked: tab.relPath === activePath, icon: tab.pinned ? "pin" as const : undefined,
|
label: tab.name, radio: true, checked: tab.relPath === activePath,
|
||||||
shortcut: tab.dirty ? $t("Unsaved") : undefined,
|
shortcut: [tab.pinned ? $t("Pinned") : "", tab.dirty ? $t("Unsaved") : ""].filter(Boolean).join(" · ") || undefined,
|
||||||
// As with a click on the tab, the workbench then focuses the document.
|
// As with a click on the tab, the workbench then focuses the document.
|
||||||
run: () => { closeMenu(); onSelect(tab.relPath); },
|
run: () => { closeMenu(); onSelect(tab.relPath); },
|
||||||
})), () => closeMenu(true), $t("All tabs"));
|
})), () => closeMenu(true), $t("All tabs"));
|
||||||
|
|||||||
@@ -28,6 +28,9 @@
|
|||||||
dropTarget: DropTarget | null;
|
dropTarget: DropTarget | null;
|
||||||
dragRel: string | null;
|
dragRel: string | null;
|
||||||
onDragPointerDown: (entry: TreeEntry, event: PointerEvent) => void;
|
onDragPointerDown: (entry: TreeEntry, event: PointerEvent) => void;
|
||||||
|
/** The row with the only Tab stop of the tree. */
|
||||||
|
tabStop: string | null;
|
||||||
|
onFocusRow: (rel: string) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
let {
|
let {
|
||||||
@@ -49,6 +52,8 @@
|
|||||||
dropTarget,
|
dropTarget,
|
||||||
dragRel,
|
dragRel,
|
||||||
onDragPointerDown,
|
onDragPointerDown,
|
||||||
|
tabStop,
|
||||||
|
onFocusRow,
|
||||||
}: Props = $props();
|
}: Props = $props();
|
||||||
|
|
||||||
let isOpen = $derived(expanded.has(entry.rel_path));
|
let isOpen = $derived(expanded.has(entry.rel_path));
|
||||||
@@ -93,7 +98,7 @@
|
|||||||
data-tree-rel={entry.rel_path}
|
data-tree-rel={entry.rel_path}
|
||||||
data-tree-kind={entry.kind}
|
data-tree-kind={entry.kind}
|
||||||
role="treeitem"
|
role="treeitem"
|
||||||
tabindex="0"
|
tabindex={entry.rel_path === tabStop ? 0 : -1}
|
||||||
aria-selected={isSelected}
|
aria-selected={isSelected}
|
||||||
aria-expanded={entry.kind === "folder" ? isOpen : undefined}
|
aria-expanded={entry.kind === "folder" ? isOpen : undefined}
|
||||||
aria-level={entry.rel_path.split("/").length}
|
aria-level={entry.rel_path.split("/").length}
|
||||||
@@ -102,6 +107,7 @@
|
|||||||
onDragPointerDown(entry, event);
|
onDragPointerDown(entry, event);
|
||||||
}}
|
}}
|
||||||
onclick={(event) => onRowClick(entry, event)}
|
onclick={(event) => onRowClick(entry, event)}
|
||||||
|
onfocus={(event) => { if (event.target === event.currentTarget) onFocusRow(entry.rel_path); }}
|
||||||
onauxclick={(event) => {
|
onauxclick={(event) => {
|
||||||
if (event.button !== 1) return;
|
if (event.button !== 1) return;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -184,6 +190,8 @@
|
|||||||
{dropTarget}
|
{dropTarget}
|
||||||
{dragRel}
|
{dragRel}
|
||||||
{onDragPointerDown}
|
{onDragPointerDown}
|
||||||
|
{tabStop}
|
||||||
|
{onFocusRow}
|
||||||
/>
|
/>
|
||||||
{/each}
|
{/each}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -1104,6 +1104,18 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A splitter takes keyboard focus. The arrow keys move it by 16 pixels, and Home and End go to its limits.
|
||||||
|
function splitterKey(event: KeyboardEvent, pane: "left" | "right" | "bottom") {
|
||||||
|
const steps: Record<string, number> = pane === "bottom" ? { ArrowUp: 16, ArrowDown: -16 } : pane === "left" ? { ArrowRight: 16, ArrowLeft: -16 } : { ArrowLeft: 16, ArrowRight: -16 };
|
||||||
|
const [min, max] = pane === "bottom" ? [80, Math.max(80, (centerStack?.getBoundingClientRect().height ?? 400) - 80)] : [160, 480];
|
||||||
|
const current = pane === "left" ? leftWidth : pane === "right" ? rightWidth : bottomHeight;
|
||||||
|
const next = event.key === "Home" ? min : event.key === "End" ? max : event.key in steps ? current + steps[event.key] : null;
|
||||||
|
if (next === null) return;
|
||||||
|
event.preventDefault();
|
||||||
|
const value = Math.min(max, Math.max(min, next));
|
||||||
|
if (pane === "left") leftWidth = value; else if (pane === "right") rightWidth = value; else bottomHeight = value;
|
||||||
|
}
|
||||||
|
|
||||||
function updateSettings(next: AppSettings) {
|
function updateSettings(next: AppSettings) {
|
||||||
const saved = saveSettings(next);
|
const saved = saveSettings(next);
|
||||||
settings = { ...next };
|
settings = { ...next };
|
||||||
@@ -1266,10 +1278,18 @@
|
|||||||
onStatus={(message) => { status = message; error = null; }}
|
onStatus={(message) => { status = message; error = null; }}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<!-- svelte-ignore a11y_no_noninteractive_tabindex, a11y_no_noninteractive_element_interactions (A focusable separator is the splitter pattern.) -->
|
||||||
<div
|
<div
|
||||||
class="gutter gutter-v"
|
class="gutter gutter-v"
|
||||||
role="separator"
|
role="separator"
|
||||||
|
tabindex="0"
|
||||||
|
aria-orientation="vertical"
|
||||||
|
aria-label={$t("Resize the side pane")}
|
||||||
|
aria-valuenow={leftWidth}
|
||||||
|
aria-valuemin={160}
|
||||||
|
aria-valuemax={480}
|
||||||
onpointerdown={() => (dragging = "left")}
|
onpointerdown={() => (dragging = "left")}
|
||||||
|
onkeydown={(event) => splitterKey(event, "left")}
|
||||||
></div>
|
></div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
@@ -1310,10 +1330,17 @@
|
|||||||
onOpenLink={(pane, kind, target) => void openLink(kind, target, pane.buffer?.relPath ?? "", pane.id)}
|
onOpenLink={(pane, kind, target) => void openLink(kind, target, pane.buffer?.relPath ?? "", pane.id)}
|
||||||
/>
|
/>
|
||||||
{#if terminalContribution && terminalStarted}
|
{#if terminalContribution && terminalStarted}
|
||||||
|
<!-- svelte-ignore a11y_no_noninteractive_tabindex, a11y_no_noninteractive_element_interactions (A focusable separator is the splitter pattern.) -->
|
||||||
<div
|
<div
|
||||||
class="gutter gutter-h" class:terminal-hidden={!terminalOpen}
|
class="gutter gutter-h" class:terminal-hidden={!terminalOpen}
|
||||||
role="separator"
|
role="separator"
|
||||||
|
tabindex="0"
|
||||||
|
aria-orientation="horizontal"
|
||||||
|
aria-label={$t("Resize the terminal")}
|
||||||
|
aria-valuenow={bottomHeight}
|
||||||
|
aria-valuemin={80}
|
||||||
onpointerdown={() => (dragging = "bottom")}
|
onpointerdown={() => (dragging = "bottom")}
|
||||||
|
onkeydown={(event) => splitterKey(event, "bottom")}
|
||||||
></div>
|
></div>
|
||||||
<section class="bottom" class:terminal-hidden={!terminalOpen}>
|
<section class="bottom" class:terminal-hidden={!terminalOpen}>
|
||||||
{#if workspace}
|
{#if workspace}
|
||||||
@@ -1331,10 +1358,18 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if rightOpen && !transferredWindow}
|
{#if rightOpen && !transferredWindow}
|
||||||
|
<!-- svelte-ignore a11y_no_noninteractive_tabindex, a11y_no_noninteractive_element_interactions (A focusable separator is the splitter pattern.) -->
|
||||||
<div
|
<div
|
||||||
class="gutter gutter-v"
|
class="gutter gutter-v"
|
||||||
role="separator"
|
role="separator"
|
||||||
|
tabindex="0"
|
||||||
|
aria-orientation="vertical"
|
||||||
|
aria-label={$t("Resize the outline")}
|
||||||
|
aria-valuenow={rightWidth}
|
||||||
|
aria-valuemin={160}
|
||||||
|
aria-valuemax={480}
|
||||||
onpointerdown={() => (dragging = "right")}
|
onpointerdown={() => (dragging = "right")}
|
||||||
|
onkeydown={(event) => splitterKey(event, "right")}
|
||||||
></div>
|
></div>
|
||||||
<RightPane
|
<RightPane
|
||||||
{outlineItems}
|
{outlineItems}
|
||||||
|
|||||||
@@ -164,7 +164,7 @@
|
|||||||
form button { display: flex; align-items: center; gap: 10px; background: transparent; border: 1px solid transparent; border-radius: var(--rs-control-radius); padding: 9px 10px; color: var(--rs-text); text-align: left; }
|
form button { display: flex; align-items: center; gap: 10px; background: transparent; border: 1px solid transparent; border-radius: var(--rs-control-radius); padding: 9px 10px; color: var(--rs-text); text-align: left; }
|
||||||
form button:hover { background: var(--rs-bg-active); }
|
form button:hover { background: var(--rs-bg-active); }
|
||||||
form button:focus-visible, input:focus-visible { outline: 2px solid var(--rs-focus); outline-offset: -2px; }
|
form button:focus-visible, input:focus-visible { outline: 2px solid var(--rs-focus); outline-offset: -2px; }
|
||||||
form button:disabled { opacity: .5; }
|
form button:disabled { color: var(--rs-text-dim); }
|
||||||
.workspace-row, footer button { width: 100%; }
|
.workspace-row, footer button { width: 100%; }
|
||||||
.workspace-entry { display: flex; align-items: stretch; }
|
.workspace-entry { display: flex; align-items: stretch; }
|
||||||
.workspace-entry .workspace-row { flex: 1; min-width: 0; }
|
.workspace-entry .workspace-row { flex: 1; min-width: 0; }
|
||||||
|
|||||||
@@ -84,6 +84,8 @@ export const OTHER_SHORTCUTS: readonly { section: string; label: string; keys: s
|
|||||||
{ section: message("Write"), label: message("Strikethrough"), keys: "Mod+Shift+X" },
|
{ section: message("Write"), label: message("Strikethrough"), keys: "Mod+Shift+X" },
|
||||||
{ section: message("Write"), label: message("Highlight"), keys: "Mod+Shift+H" },
|
{ section: message("Write"), label: message("Highlight"), keys: "Mod+Shift+H" },
|
||||||
{ section: message("Write"), label: message("Find in the document"), keys: "Mod+F" },
|
{ section: message("Write"), label: message("Find in the document"), keys: "Mod+F" },
|
||||||
|
// Tab indents in the editor. Escape first leaves the text, so the next Tab moves the focus on.
|
||||||
|
{ section: message("Write"), label: message("Leave the text, then press Tab"), keys: "Escape" },
|
||||||
{ section: message("Files"), label: message("Rename"), keys: "F2" },
|
{ section: message("Files"), label: message("Rename"), keys: "F2" },
|
||||||
{ section: message("Files"), label: message("Move to the Recycle Bin"), keys: "Delete", macKeys: "Mod+Backspace" },
|
{ section: message("Files"), label: message("Move to the Recycle Bin"), keys: "Delete", macKeys: "Mod+Backspace" },
|
||||||
{ section: message("Files"), label: message("Delete permanently"), keys: "Shift+Delete", macKeys: "Mod+Alt+Backspace" },
|
{ section: message("Files"), label: message("Delete permanently"), keys: "Shift+Delete", macKeys: "Mod+Alt+Backspace" },
|
||||||
|
|||||||
@@ -202,7 +202,7 @@
|
|||||||
p { margin: 6px 0 10px; color: var(--rs-text-dim); line-height: 1.45; }
|
p { margin: 6px 0 10px; color: var(--rs-text-dim); line-height: 1.45; }
|
||||||
button { display: inline-flex; align-items: center; justify-content: center; gap: var(--rs-settings-gap); min-height: var(--rs-settings-control-height); padding: 4px 8px; color: var(--rs-text); background: var(--rs-bg-elevated); border: 1px solid var(--rs-border); border-radius: var(--rs-control-radius); }
|
button { display: inline-flex; align-items: center; justify-content: center; gap: var(--rs-settings-gap); min-height: var(--rs-settings-control-height); padding: 4px 8px; color: var(--rs-text); background: var(--rs-bg-elevated); border: 1px solid var(--rs-border); border-radius: var(--rs-control-radius); }
|
||||||
button:hover:not(:disabled) { background: var(--rs-bg-active); }
|
button:hover:not(:disabled) { background: var(--rs-bg-active); }
|
||||||
button:disabled { opacity: .5; }
|
button:disabled { color: var(--rs-text-dim); }
|
||||||
.toolbar, footer { display: flex; align-items: center; flex-wrap: wrap; gap: var(--rs-settings-gap); }
|
.toolbar, footer { display: flex; align-items: center; flex-wrap: wrap; gap: var(--rs-settings-gap); }
|
||||||
.card { border-bottom: 1px solid var(--rs-border); }
|
.card { border-bottom: 1px solid var(--rs-border); }
|
||||||
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: var(--rs-settings-row-padding) 0; }
|
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: var(--rs-settings-row-padding) 0; }
|
||||||
|
|||||||
@@ -34,14 +34,16 @@ button {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* A disabled control uses dim text at full opacity, so it stays readable. */
|
||||||
button:disabled {
|
button:disabled {
|
||||||
cursor: default;
|
cursor: default;
|
||||||
opacity: 0.5;
|
color: var(--rs-text-dim);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Keyboard focus: a 2-pixel ring outside the control. */
|
||||||
:focus-visible {
|
:focus-visible {
|
||||||
outline: 1px solid var(--rs-focus);
|
outline: 2px solid var(--rs-focus);
|
||||||
outline-offset: -1px;
|
outline-offset: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
::selection {
|
::selection {
|
||||||
|
|||||||
@@ -127,19 +127,27 @@
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
border: 1px solid transparent;
|
border: 1px solid transparent;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
color: var(--rs-text-dim);
|
color: var(--rs-text);
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-btn:hover,
|
/* Hover gets a neutral fill. An active toggle also gets the accent color and an accent bar. A disabled button is dim. */
|
||||||
.icon-btn.active {
|
.icon-btn:not(:disabled):hover {
|
||||||
background: var(--rs-bg-active);
|
background: var(--rs-bg-active);
|
||||||
border-color: var(--rs-border);
|
border-color: var(--rs-border);
|
||||||
color: var(--rs-accent);
|
color: var(--rs-text-strong);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.icon-btn.active {
|
||||||
|
background: var(--rs-item-selection-bg);
|
||||||
|
color: var(--rs-accent);
|
||||||
|
box-shadow: inset 0 -2px 0 var(--rs-accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-btn:disabled { color: var(--rs-text-dim); }
|
||||||
|
|
||||||
.tip {
|
.tip {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
inset: auto;
|
inset: auto;
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
import { actionIcon, type ActionIcon } from "./actionIcons.ts";
|
import { actionIcon, type ActionIcon } from "./actionIcons.ts";
|
||||||
|
|
||||||
|
/** The check mark of the current radio row. It sits in the icon column and replaces the icon of the row. */
|
||||||
|
function checkMark() {
|
||||||
|
const svg = actionIcon("task");
|
||||||
|
svg.innerHTML = '<path d="M5 12.5 9.5 17 19 7"/>';
|
||||||
|
return svg;
|
||||||
|
}
|
||||||
|
|
||||||
export type ActionMenuItem = { label: string; icon?: ActionIcon; shortcut?: string; run?: () => void; children?: ActionMenuItem[]; disabled?: boolean; checked?: boolean; radio?: boolean; title?: string } | { separator: true };
|
export type ActionMenuItem = { label: string; icon?: ActionIcon; shortcut?: string; run?: () => void; children?: ActionMenuItem[]; disabled?: boolean; checked?: boolean; radio?: boolean; title?: string } | { separator: true };
|
||||||
|
|
||||||
export function actionMenu(x: number, y: number, items: ActionMenuItem[], onClose: () => void, label = "Table actions", parent: HTMLElement = document.body) {
|
export function actionMenu(x: number, y: number, items: ActionMenuItem[], onClose: () => void, label = "Table actions", parent: HTMLElement = document.body) {
|
||||||
@@ -32,7 +39,7 @@ export function actionMenu(x: number, y: number, items: ActionMenuItem[], onClos
|
|||||||
if (focus) focusRow(panel.querySelector<HTMLButtonElement>("button:not(:disabled)") ?? undefined);
|
if (focus) focusRow(panel.querySelector<HTMLButtonElement>("button:not(:disabled)") ?? undefined);
|
||||||
}
|
}
|
||||||
function populate(panel: HTMLElement, entries: ActionMenuItem[]) {
|
function populate(panel: HTMLElement, entries: ActionMenuItem[]) {
|
||||||
const hasIcons = entries.some(item => !("separator" in item) && (!!item.icon || (item.checked !== undefined && !item.radio)));
|
const hasIcons = entries.some(item => !("separator" in item) && (!!item.icon || item.checked !== undefined));
|
||||||
panel.classList.toggle("rs-menu-text", !hasIcons);
|
panel.classList.toggle("rs-menu-text", !hasIcons);
|
||||||
for (const item of entries) {
|
for (const item of entries) {
|
||||||
if ("separator" in item) { const hr = document.createElement("hr"); hr.setAttribute("role", "separator"); panel.append(hr); continue; }
|
if ("separator" in item) { const hr = document.createElement("hr"); hr.setAttribute("role", "separator"); panel.append(hr); continue; }
|
||||||
@@ -40,7 +47,8 @@ export function actionMenu(x: number, y: number, items: ActionMenuItem[], onClos
|
|||||||
if (item.checked !== undefined) { button.setAttribute("role", item.radio ? "menuitemradio" : "menuitemcheckbox"); button.setAttribute("aria-checked", String(item.checked)); }
|
if (item.checked !== undefined) { button.setAttribute("role", item.radio ? "menuitemradio" : "menuitemcheckbox"); button.setAttribute("aria-checked", String(item.checked)); }
|
||||||
if (item.title) button.title = item.title;
|
if (item.title) button.title = item.title;
|
||||||
const label = document.createElement("span"); label.className = "action-label"; label.textContent = item.label;
|
const label = document.createElement("span"); label.className = "action-label"; label.textContent = item.label;
|
||||||
const icon = item.checked && !item.radio ? actionIcon("task") : item.icon ? actionIcon(item.icon) : document.createElement("span");
|
const icon = item.radio ? (item.checked ? checkMark() : document.createElement("span"))
|
||||||
|
: item.checked ? actionIcon("task") : item.icon ? actionIcon(item.icon) : document.createElement("span");
|
||||||
icon.classList.add("action-icon"); icon.setAttribute("aria-hidden", "true");
|
icon.classList.add("action-icon"); icon.setAttribute("aria-hidden", "true");
|
||||||
button.append(icon, label); panel.append(button);
|
button.append(icon, label); panel.append(button);
|
||||||
if (item.shortcut) { const shortcut = document.createElement("span"); shortcut.textContent = item.shortcut; shortcut.style.cssText = "margin-left:auto;color:var(--rs-text-dim);font-size:12px;white-space:nowrap"; button.append(shortcut); }
|
if (item.shortcut) { const shortcut = document.createElement("span"); shortcut.textContent = item.shortcut; shortcut.style.cssText = "margin-left:auto;color:var(--rs-text-dim);font-size:12px;white-space:nowrap"; button.append(shortcut); }
|
||||||
|
|||||||
+8
-2
@@ -35,14 +35,20 @@
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rs-menu > button:disabled, .rs-picker .rs-picker-row:disabled { opacity: .4; cursor: default; }
|
/* Disabled rows stay readable: dim text at full opacity. */
|
||||||
.rs-menu > button[role="menuitemradio"][aria-checked="true"] { background: var(--rs-menu-active-bg); }
|
.rs-menu > button:disabled, .rs-picker .rs-picker-row:disabled { color: var(--rs-text-dim); cursor: default; }
|
||||||
.rs-menu.rs-menu-text > button > .action-icon { display: none; }
|
.rs-menu.rs-menu-text > button > .action-icon { display: none; }
|
||||||
|
/* Hover gets only the quiet fill. The current radio row shows a check mark, not a fill. */
|
||||||
.rs-menu > button:not(:disabled):is(:hover, :focus-visible, [aria-expanded="true"]),
|
.rs-menu > button:not(:disabled):is(:hover, :focus-visible, [aria-expanded="true"]),
|
||||||
.rs-picker .rs-picker-row:not(:disabled):is(:hover, :focus-visible, :focus-within, [aria-selected="true"], [aria-current="true"]) {
|
.rs-picker .rs-picker-row:not(:disabled):is(:hover, :focus-visible, :focus-within, [aria-selected="true"], [aria-current="true"]) {
|
||||||
background: var(--rs-menu-active-bg);
|
background: var(--rs-menu-active-bg);
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
|
/* Keyboard focus also gets a 2-pixel ring, so it differs from hover. */
|
||||||
|
.rs-menu > button:not(:disabled):focus-visible, .rs-picker .rs-picker-row:not(:disabled):focus-visible {
|
||||||
|
outline: 2px solid var(--rs-focus);
|
||||||
|
outline-offset: -2px;
|
||||||
|
}
|
||||||
.rs-menu > hr { margin: 4px 0; border: 0; border-top: 1px solid var(--rs-border); }
|
.rs-menu > hr { margin: 4px 0; border: 0; border-top: 1px solid var(--rs-border); }
|
||||||
.rs-menu > button > .action-icon, .rs-picker-icon { width: var(--rs-menu-icon-size); height: var(--rs-menu-icon-size); flex: 0 0 var(--rs-menu-icon-size); }
|
.rs-menu > button > .action-icon, .rs-picker-icon { width: var(--rs-menu-icon-size); height: var(--rs-menu-icon-size); flex: 0 0 var(--rs-menu-icon-size); }
|
||||||
.rs-picker-hint { display: block; color: var(--rs-text-dim); font-size: var(--rs-settings-description-size); }
|
.rs-picker-hint { display: block; color: var(--rs-text-dim); font-size: var(--rs-settings-description-size); }
|
||||||
|
|||||||
@@ -89,7 +89,8 @@ await runSmoke('appearance/backgroundImages', async ({ browser }) => {
|
|||||||
assert.equal(await menu.evaluate(node => getComputedStyle(node).fontSize), '13px');
|
assert.equal(await menu.evaluate(node => getComputedStyle(node).fontSize), '13px');
|
||||||
// Shared menu rows are 24px high (src/lib/theme/tokens.css:31, --rs-menu-row-height).
|
// Shared menu rows are 24px high (src/lib/theme/tokens.css:31, --rs-menu-row-height).
|
||||||
assert.equal(await menu.locator(':scope > button').first().evaluate(node => getComputedStyle(node).minHeight), '24px');
|
assert.equal(await menu.locator(':scope > button').first().evaluate(node => getComputedStyle(node).minHeight), '24px');
|
||||||
assert.equal(await menu.locator('[aria-checked="true"] svg').count(), 0);
|
// The current choice shows a check mark in the icon column (src/lib/ui/actionMenu.ts).
|
||||||
|
assert.equal(await menu.locator('[aria-checked="true"] svg').count(), 1);
|
||||||
assert.equal(await menu.evaluate(node => { const reference = document.createElement('span'); reference.style.color = 'var(--rs-menu-border)'; node.append(reference); const matches = getComputedStyle(node).borderColor === getComputedStyle(reference).color; reference.remove(); return matches; }), true, 'Menu uses the shared border token');
|
assert.equal(await menu.evaluate(node => { const reference = document.createElement('span'); reference.style.color = 'var(--rs-menu-border)'; node.append(reference); const matches = getComputedStyle(node).borderColor === getComputedStyle(reference).color; reference.remove(); return matches; }), true, 'Menu uses the shared border token');
|
||||||
assert.equal(await menu.evaluate(node => getComputedStyle(node).borderColor), 'rgba(0, 0, 0, 0)', 'Menus have no visible border');
|
assert.equal(await menu.evaluate(node => getComputedStyle(node).borderColor), 'rgba(0, 0, 0, 0)', 'Menus have no visible border');
|
||||||
await settings.screenshot({ path: `${output}/${name.replaceAll(' ', '-')}-${mode}.png` });
|
await settings.screenshot({ path: `${output}/${name.replaceAll(' ', '-')}-${mode}.png` });
|
||||||
|
|||||||
@@ -0,0 +1,148 @@
|
|||||||
|
// Keyboard and focus: radio check marks, menu focus rings, hover against active, readable disabled controls, the file tree keys, and splitters.
|
||||||
|
import assert from "node:assert/strict";
|
||||||
|
import { mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
||||||
|
|
||||||
|
await runSmoke("layout/keyboardFocus", async ({ page }) => {
|
||||||
|
const output = await outputDir("layout/keyboardFocus");
|
||||||
|
await mockTauri(page, {
|
||||||
|
commands: test => ({
|
||||||
|
...test.workspace({
|
||||||
|
root: "C:\\keyboard",
|
||||||
|
files: {
|
||||||
|
"alpha.md": "# Alpha\n",
|
||||||
|
"beta.md": "# Beta\n",
|
||||||
|
"notes/first.md": "# First\n",
|
||||||
|
"notes/second.md": "# Second\n",
|
||||||
|
"notes/deep/third.md": "# Third\n",
|
||||||
|
"zeta.txt": "Zeta\n",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
plugins_snapshot: () => ({ root: "C:/plugins", plugins: [] }),
|
||||||
|
"plugin:window|is_maximized": () => false,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
await page.setViewportSize({ width: 1280, height: 760 });
|
||||||
|
await page.goto(smokeUrl);
|
||||||
|
const tree = page.getByRole("tree", { name: "Workspace files" });
|
||||||
|
const row = rel => page.locator(`[data-tree-rel="${rel}"]`);
|
||||||
|
const focused = () => page.evaluate(() => document.activeElement?.getAttribute("data-tree-rel") ?? document.activeElement?.getAttribute("aria-label"));
|
||||||
|
await row("alpha.md").waitFor();
|
||||||
|
|
||||||
|
// The tree has one Tab stop. Arrow keys move, Right opens or enters a folder, Left closes it or goes up.
|
||||||
|
assert.equal(await tree.locator('[role="treeitem"][tabindex="0"]').count(), 1);
|
||||||
|
await row("alpha.md").click();
|
||||||
|
await page.getByRole("tab", { name: "alpha.md", exact: true, selected: true }).waitFor();
|
||||||
|
await row("alpha.md").focus();
|
||||||
|
await page.keyboard.press("ArrowDown");
|
||||||
|
assert.equal(await focused(), "beta.md");
|
||||||
|
assert.equal(await row("beta.md").getAttribute("aria-selected"), "true");
|
||||||
|
// Folders come first: notes, alpha.md, beta.md, zeta.txt.
|
||||||
|
await page.keyboard.press("ArrowDown");
|
||||||
|
assert.equal(await focused(), "zeta.txt");
|
||||||
|
await page.keyboard.press("Home");
|
||||||
|
assert.equal(await focused(), "notes");
|
||||||
|
await page.keyboard.press("ArrowRight");
|
||||||
|
await row("notes/first.md").waitFor();
|
||||||
|
assert.equal(await row("notes").getAttribute("aria-expanded"), "true");
|
||||||
|
await page.keyboard.press("ArrowRight");
|
||||||
|
assert.equal(await focused(), "notes/deep");
|
||||||
|
await page.keyboard.press("ArrowLeft");
|
||||||
|
assert.equal(await focused(), "notes");
|
||||||
|
await page.keyboard.press("ArrowLeft");
|
||||||
|
assert.equal(await row("notes").getAttribute("aria-expanded"), "false");
|
||||||
|
await page.keyboard.press("End");
|
||||||
|
assert.equal(await focused(), "zeta.txt");
|
||||||
|
await page.keyboard.press("Home");
|
||||||
|
assert.equal(await focused(), "notes");
|
||||||
|
await page.keyboard.press("z");
|
||||||
|
assert.equal(await focused(), "zeta.txt");
|
||||||
|
await page.keyboard.press("Shift+ArrowUp");
|
||||||
|
assert.equal(await tree.locator('[aria-selected="true"]').count(), 2);
|
||||||
|
assert.equal(await tree.locator('[role="treeitem"][tabindex="0"]').count(), 1);
|
||||||
|
// Tab leaves the tree at once.
|
||||||
|
await page.keyboard.press("Tab");
|
||||||
|
assert.notEqual(await page.evaluate(() => !!document.activeElement?.closest('[role="tree"]')), true);
|
||||||
|
await page.keyboard.press("Shift+Tab");
|
||||||
|
assert.equal(await page.evaluate(() => !!document.activeElement?.closest('[role="tree"]')), true);
|
||||||
|
|
||||||
|
// A splitter takes focus. The arrow keys move it by 16 pixels, and Home and End go to its limits.
|
||||||
|
const splitter = page.getByRole("separator", { name: "Resize the side pane", exact: true });
|
||||||
|
const width = () => page.locator("aside.left").evaluate(node => Math.round(node.getBoundingClientRect().width));
|
||||||
|
const before = await width();
|
||||||
|
await splitter.focus();
|
||||||
|
await page.keyboard.press("ArrowRight");
|
||||||
|
assert.equal(await width(), before + 16);
|
||||||
|
assert.equal(await splitter.getAttribute("aria-valuenow"), String(before + 16));
|
||||||
|
await page.keyboard.press("Home");
|
||||||
|
assert.equal(await width(), 160);
|
||||||
|
await page.keyboard.press("End");
|
||||||
|
assert.equal(await width(), 480);
|
||||||
|
assert.equal(await splitter.evaluate(node => getComputedStyle(node).outlineWidth), "2px");
|
||||||
|
const outline = page.getByRole("separator", { name: "Resize the outline", exact: true });
|
||||||
|
await outline.focus();
|
||||||
|
const right = () => page.locator("aside.right").evaluate(node => Math.round(node.getBoundingClientRect().width));
|
||||||
|
const rightBefore = await right();
|
||||||
|
await page.keyboard.press("ArrowLeft");
|
||||||
|
assert.equal(await right(), rightBefore + 16);
|
||||||
|
await splitter.focus();
|
||||||
|
await page.keyboard.press("Home");
|
||||||
|
|
||||||
|
for (const theme of ["dark", "light"]) {
|
||||||
|
await page.evaluate(async mode => { const { saveAppearance } = await import("/src/lib/theme/appearance.ts"); saveAppearance({ theme: "default", mode }); window.dispatchEvent(new Event("focus")); }, theme);
|
||||||
|
await page.waitForFunction(mode => document.documentElement.dataset.theme === mode, theme);
|
||||||
|
|
||||||
|
// An active toggle differs from a hovered button. A disabled button keeps full opacity and dim text.
|
||||||
|
const files = page.getByRole("button", { name: "Files", exact: true });
|
||||||
|
const search = page.getByRole("button", { name: "Search", exact: true });
|
||||||
|
await search.hover();
|
||||||
|
const look = locator => locator.evaluate(node => { const style = getComputedStyle(node); return { fill: style.backgroundColor, color: style.color, bar: style.boxShadow }; });
|
||||||
|
const [hovered, active] = [await look(search), await look(files)];
|
||||||
|
assert.equal(hovered.bar, "none");
|
||||||
|
assert.match(active.bar, /inset/);
|
||||||
|
assert.notEqual(hovered.color, active.color);
|
||||||
|
const save = page.getByRole("button", { name: "Save", exact: true });
|
||||||
|
assert.equal(await save.isDisabled(), true);
|
||||||
|
assert.equal(await save.evaluate(node => getComputedStyle(node).opacity), "1");
|
||||||
|
const dim = await page.evaluate(() => { const probe = document.createElement("span"); probe.style.color = "var(--rs-text-dim)"; document.body.append(probe); const color = getComputedStyle(probe).color; probe.remove(); return color; });
|
||||||
|
assert.equal(await save.evaluate(node => getComputedStyle(node).color), dim);
|
||||||
|
await page.locator("header.header").screenshot({ path: `${output}/header-states-${theme}.png` });
|
||||||
|
|
||||||
|
// The current radio row shows a check mark and no fill. Keyboard focus adds a ring that hover does not have.
|
||||||
|
await page.getByRole("tab", { name: "alpha.md", exact: true }).click({ button: "right" });
|
||||||
|
await page.getByRole("menuitem", { name: "View", exact: true }).click();
|
||||||
|
const write = page.getByRole("menuitemradio", { name: "Write", exact: true });
|
||||||
|
const source = page.getByRole("menuitemradio", { name: "Source", exact: true });
|
||||||
|
assert.equal(await write.getAttribute("aria-checked"), "true");
|
||||||
|
assert.equal(await write.locator("svg").count(), 1);
|
||||||
|
assert.equal(await source.locator("svg").count(), 0);
|
||||||
|
await source.hover();
|
||||||
|
assert.equal(await source.evaluate(node => getComputedStyle(node).outlineStyle), "none");
|
||||||
|
await write.focus();
|
||||||
|
await page.keyboard.press("ArrowDown");
|
||||||
|
const keyed = page.locator('[role="menu"] button:focus-visible');
|
||||||
|
assert.equal(await keyed.getAttribute("aria-checked"), "false");
|
||||||
|
assert.equal(await keyed.evaluate(node => getComputedStyle(node).outlineWidth), "2px");
|
||||||
|
// With focus and the pointer on other rows, the checked row has no fill.
|
||||||
|
await page.mouse.move(0, 700);
|
||||||
|
assert.equal(await write.evaluate(node => getComputedStyle(node).backgroundColor), "rgba(0, 0, 0, 0)");
|
||||||
|
await page.screenshot({ path: `${output}/menu-check-${theme}.png` });
|
||||||
|
await page.keyboard.press("Escape");
|
||||||
|
await page.keyboard.press("Escape");
|
||||||
|
await page.keyboard.press("Escape");
|
||||||
|
|
||||||
|
// Disabled menu rows keep full opacity and dim text.
|
||||||
|
await page.getByRole("tab", { name: "alpha.md", exact: true }).click({ button: "right" });
|
||||||
|
const disabled = page.getByRole("menuitem", { name: "Close tabs after", exact: true });
|
||||||
|
assert.equal(await disabled.isDisabled(), true);
|
||||||
|
assert.equal(await disabled.evaluate(node => getComputedStyle(node).opacity), "1");
|
||||||
|
assert.equal(await disabled.evaluate(node => getComputedStyle(node).color), dim);
|
||||||
|
await page.keyboard.press("Escape");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Help names the key that leaves the text before Tab moves on.
|
||||||
|
await page.keyboard.press("F1");
|
||||||
|
await page.getByRole("dialog", { name: "Help and about" }).getByText("Leave the text, then press Tab", { exact: true }).waitFor();
|
||||||
|
await page.getByRole("button", { name: "Close help", exact: true }).click();
|
||||||
|
assert.deepEqual(page.errors, []);
|
||||||
|
console.log("PASS: one tree Tab stop, tree keys, type-ahead, range selection, keyboard splitters, radio check marks, menu focus ring, hover against active, readable disabled controls, Help, both themes.");
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user