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')
This commit is contained in:
@@ -270,7 +270,9 @@ async function dispatch(action: string): Promise<void> {
|
|||||||
|
|
||||||
// App actions
|
// App actions
|
||||||
case 'app.selectAll':
|
case 'app.selectAll':
|
||||||
document.execCommand('selectAll');
|
document.dispatchEvent(
|
||||||
|
new CustomEvent('shortcut:select-all'),
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Panel-specific: track list
|
// Panel-specific: track list
|
||||||
|
|||||||
@@ -135,6 +135,24 @@ export class SelectionController implements ReactiveController {
|
|||||||
this.host.onSelectionChanged?.();
|
this.host.onSelectionChanged?.();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Select all items. */
|
||||||
|
selectAll(): void {
|
||||||
|
const count = this.host.getItemCount();
|
||||||
|
const next = new Set<string>();
|
||||||
|
|
||||||
|
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
|
* Return the selected keys in the order they appear in the host's
|
||||||
* item list. This preserves positional ordering for queue operations.
|
* item list. This preserves positional ordering for queue operations.
|
||||||
|
|||||||
Reference in New Issue
Block a user