Change:
Testing focus on trusted URI list of items tab to navigate to the X to remove an item. Press to trigger removal nicely gets removed from the list, however focus is lost Focus should be preserved in the list on the neighbour item (example: checkout how Explorer does that when deleting a file). I thought this would be tackled via
The trust editor does a lot of full page re-rendering which I should improve (remove) so I doubt this is an issue with the table widget itself.

Discussion:
class Trait<T> implements ISpliceable<boolean>, IDisposable { <del> private length = 0; private indexes: number[] = []; private sortedIndexes: number[] = []; </del> <ins> protected indexes: number[] = []; protected sortedIndexes: number[] = []; </ins> private readonly _onChange = new Emitter<ITraitChangeEvent>(); readonly onChange: Event<ITraitChangeEvent> = this._onChange.event;

constructor(private _trait: string) { } splice(start: number, deleteCount: number, elements: boolean[]): void { <del> deleteCount = Math.max(0, Math.min(deleteCount, this.length - start)); </del> const diff = elements.length - deleteCount; const end = start + deleteCount; const sortedIndexes: number[] = [];

sortedIndexes.push(this.sortedIndexes[i++] + diff); } <del> const length = this.length + diff; if (this.sortedIndexes.length > 0 && sortedIndexes.length === 0 && length > 0) { const first = this.sortedIndexes.find(index => index >= start) ?? length - 1; sortedIndexes.push(Math.min(first, length - 1)); } </del> this.renderer.splice(start, deleteCount, elements.length); this._set(sortedIndexes, sortedIndexes); <del> this.length = length; </del> } renderIndex(index: number, container: HTMLElement): void {

// Remove Element from Parent (Model) const parent = modelElement.parent; parent.removeChild(modelElement); <ins> this.view?.focusNext(); </ins> const oldNestedParent = modelElement.nestedParent; if (oldNestedParent) {

} // Refresh Parent (View) await this.view?.refresh(shouldDeepRefresh, parent); <ins> if (this.view?.getFocus().length === 0) { this.view?.focusLast(); } </ins> } })); }

isItemVisible(item: ExplorerItem): boolean; isItemCollapsed(item: ExplorerItem): boolean; hasFocus(): boolean; <ins> getFocus(): ExplorerItem[]; focusNext(): void; focusLast(): void; </ins> } function getFocus(listService: IListService): unknown | undefined {

return DOM.isAncestorOfActiveElement(this.container); } <ins> getFocus(): ExplorerItem[] { return this.tree.getFocus(); } focusNext(): void { this.tree.focusNext(); } focusLast(): void { this.tree.focusLast(); } </ins> getContext(respectMultiSelection: boolean): ExplorerItem[] { return getContext(this.tree.getFocus(), this.tree.getSelection(), respectMultiSelection, this.renderer); }

return localize('trustedFolderWithHostAriaLabel', "{0} on {1}, trusted", this.labelService.getUriLabel(item.uri), hostLabel); }, getWidgetAriaLabel: () => localize('trustedFoldersAndWorkspaces', "Trusted Folders & Workspaces") <ins> }, identityProvider: { getId(element: ITrustedUriItem) { return element.uri.toString(); }, </ins> } } ) as WorkbenchTable<ITrustedUriItem>;

} async delete(item: ITrustedUriItem) { <ins> this.table.focusNext(); </ins> await this.workspaceTrustManagementService.setUrisTrust([item.uri], false); <ins> if (this.table.getFocus().length === 0) { this.table.focusLast(); } </ins> this._onDelete.fire(item); <ins> this.table.domFocus(); </ins> } async edit(item: ITrustedUriItem, usePickerIfPossible?: boolean) {