Skip to content

Commit cad5e06

Browse files
authored
add focus title bar command (microsoft#155347)
fixes microsoft#149739
1 parent 015d6b8 commit cad5e06

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/vs/workbench/browser/parts/titlebar/titlebarPart.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import { WindowTitle } from 'vs/workbench/browser/parts/titlebar/windowTitle';
3636
import { CommandCenterControl } from 'vs/workbench/browser/parts/titlebar/commandCenterControl';
3737
import { IHoverDelegate } from 'vs/base/browser/ui/iconLabel/iconHoverDelegate';
3838
import { IHoverService } from 'vs/workbench/services/hover/browser/hover';
39+
import { CATEGORIES } from 'vs/workbench/common/actions';
3940

4041
export class TitlebarPart extends Part implements ITitleService {
4142

@@ -328,6 +329,27 @@ export class TitlebarPart extends Part implements ITitleService {
328329

329330
this.updateStyles();
330331

332+
const that = this;
333+
registerAction2(class FocusTitleBar extends Action2 {
334+
335+
constructor() {
336+
super({
337+
id: `workbench.action.focusTitleBar`,
338+
title: { value: localize('focusTitleBar', "Focus Title Bar"), original: 'Focus Title Bar' },
339+
category: CATEGORIES.View,
340+
f1: true,
341+
});
342+
}
343+
344+
run(accessor: ServicesAccessor, ...args: any[]): void {
345+
if (that.customMenubar) {
346+
that.customMenubar.toggleFocus();
347+
} else {
348+
(that.element.querySelector('[tabindex]:not([tabindex="-1"])') as HTMLElement).focus();
349+
}
350+
}
351+
});
352+
331353
return this.element;
332354
}
333355

0 commit comments

Comments
 (0)