mirror of
https://github.com/Microsoft/vscode
synced 2024-10-03 09:54:11 +00:00
Generalize focusFirstIfNothingFocused logic to all list views
This commit is contained in:
parent
7848314d06
commit
2bdfeef828
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue