From f5677628ef283b67370630b564f23178e43da3d2 Mon Sep 17 00:00:00 2001 From: Caleb Allen Date: Sat, 7 Mar 2026 10:18:08 -0500 Subject: [PATCH] feat(16-01): add selectAll() to SelectionController and dispatch shortcut:select-all event - Add selectAll() method to SelectionController that selects all items via host interface - Change app.selectAll dispatch from document.execCommand('selectAll') to CustomEvent('shortcut:select-all') --- .../src/services/keyboard-shortcut-service.ts | 4 +++- frontend/src/utils/selection-controller.ts | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/frontend/src/services/keyboard-shortcut-service.ts b/frontend/src/services/keyboard-shortcut-service.ts index 85d0103..6478d5f 100644 --- a/frontend/src/services/keyboard-shortcut-service.ts +++ b/frontend/src/services/keyboard-shortcut-service.ts @@ -270,7 +270,9 @@ async function dispatch(action: string): Promise { // App actions case 'app.selectAll': - document.execCommand('selectAll'); + document.dispatchEvent( + new CustomEvent('shortcut:select-all'), + ); break; // Panel-specific: track list diff --git a/frontend/src/utils/selection-controller.ts b/frontend/src/utils/selection-controller.ts index 011aecc..42f7f34 100644 --- a/frontend/src/utils/selection-controller.ts +++ b/frontend/src/utils/selection-controller.ts @@ -135,6 +135,24 @@ export class SelectionController implements ReactiveController { this.host.onSelectionChanged?.(); } + /** Select all items. */ + selectAll(): void { + const count = this.host.getItemCount(); + const next = new Set(); + + for (let i = 0; i < count; i++) { + const key = this.host.getItemKey(i); + if (key !== undefined) next.add(key); + } + + if (next.size === this._selectedItems.size) return; + + this._selectedItems = next; + this.lastSelectedIndex = count > 0 ? count - 1 : null; + this.host.requestUpdate(); + this.host.onSelectionChanged?.(); + } + /** * Return the selected keys in the order they appear in the host's * item list. This preserves positional ordering for queue operations.