fix(accounts): clear multi-selection globally on Escape

Route account selection clearing through the existing window-level Escape handler so it works regardless of which account surface owns focus. Preserve text editing and open overlay behavior, and remove the misleading focus-dependent workspace handler.
This commit is contained in:
Sucukdeluxe
2026-08-15 01:53:03 +02:00
parent 007235bb38
commit b5854a2227
5 changed files with 42 additions and 25 deletions
+15
View File
@@ -1,5 +1,6 @@
import { describe, expect, it } from "vitest";
import { pruneSelection, shouldClearDownloadSelection, shouldClearDownloadSelectionOnEscape } from "../src/renderer/selection";
import * as selection from "../src/renderer/selection";
import type { SessionState } from "../src/shared/types";
function session(packageIds: string[], itemIds: string[]): Pick<SessionState, "packages" | "items"> {
@@ -62,3 +63,17 @@ describe("download selection clearing", () => {
expect(shouldClearDownloadSelectionOnEscape("TEXTAREA")).toBe(false);
});
});
describe("global Escape selection routing", () => {
it("routes Escape to the account selection even when focus is outside the account workspace", () => {
const api = selection as typeof selection & {
resolveEscapeSelectionScope?: (view: string, settingsSection: string, tagName: string, inputType?: string) => string | null;
};
expect(api.resolveEscapeSelectionScope).toBeTypeOf("function");
expect(api.resolveEscapeSelectionScope?.("settings", "accounts", "BODY")).toBe("accounts");
expect(api.resolveEscapeSelectionScope?.("settings", "accounts", "INPUT", "text")).toBeNull();
expect(api.resolveEscapeSelectionScope?.("downloads", "allgemein", "DIV")).toBe("downloads");
expect(api.resolveEscapeSelectionScope?.("history", "accounts", "DIV")).toBe("history");
});
});
+2 -6
View File
@@ -301,7 +301,6 @@ function workspaceActions(overrides: Partial<AccountWorkspaceActions> = {}): Acc
return {
onPanelChange: () => {},
onSelect: () => {},
onClearSelection: () => {},
onToggleEnabled: () => {},
onEdit: () => {},
onContextMenu: () => {},
@@ -799,18 +798,15 @@ describe("account workspace", () => {
]);
});
it("shows the selected account count and clears the selection with Escape", () => {
let cleared = 0;
it("shows the selected account count", () => {
const model = workspaceModel();
const tree = AccountWorkspace({
actions: workspaceActions({ onClearSelection: () => { cleared += 1; } }),
actions: workspaceActions(),
model: { ...model, selectedIds: model.rows.slice(0, 3).map((row) => row.id) }
});
const html = renderToStaticMarkup(tree);
expect(html).toContain(" Entfernen (3)");
tree.props.onKeyDown({ key: "Escape", preventDefault: () => {} });
expect(cleared).toBe(1);
});
it("removes the redundant global account activation switch", () => {