Generalize focusFirstIfNothingFocused logic to all list views

This commit is contained in:
Jackson Kearl 2018-07-05 14:25:30 -07:00
parent 7848314d06
commit 2bdfeef828
3 changed files with 8 additions and 5 deletions

View file

@ -904,7 +904,7 @@ export class List<T> implements ISpliceable<T>, IDisposable {
this.onDidFocus = mapEvent(domEvent(this.view.domNode, 'focus', true), () => null);
this.onDidBlur = mapEvent(domEvent(this.view.domNode, 'blur', true), () => null);
this.onDidFocus(() => this.focusFirstItemIfNothingFocused(), this, this.disposables);
this.disposables.push(new DOMFocusController(this, this.view));
if (typeof options.keyboardSupport !== 'boolean' || options.keyboardSupport) {
@ -952,6 +952,12 @@ export class List<T> implements ISpliceable<T>, IDisposable {
this.view.setScrollTop(scrollTop);
}
private focusFirstItemIfNothingFocused() {
if (this.getSelection().length === 0 && this.getFocus().length === 0) {
this.focusFirst();
}
}
domFocus(): void {
this.view.domNode.focus();
}

View file

@ -478,7 +478,7 @@ export class ExtensionsViewlet extends ViewContainerViewlet implements IExtensio
}
private focusListView(): void {
this.panels[0].focus();
(<ExtensionsListView>this.panels[0]).focus();
}
private onViewletOpen(viewlet: IViewlet): void {

View file

@ -645,9 +645,6 @@ export class ExtensionsListView extends ViewletPanel {
focus(): void {
super.focus();
this.list.domFocus();
if (this.list.getSelection().length === 0 && this.list.getFocus().length === 0) {
this.list.focusNext();
}
}
}