Set initial focus on an input field when opening the issue reporter

This commit is contained in:
Rachel Macfarlane
2019-04-12 14:25:06 -07:00
parent ceaa95c0c3
commit 9d958136be

View File

@@ -60,6 +60,7 @@ export function startup(configuration: IssueReporterConfiguration) {
const issueReporter = new IssueReporter(configuration);
issueReporter.render();
document.body.style.display = 'block';
issueReporter.setInitialFocus();
}
export class IssueReporter extends Disposable {
@@ -142,6 +143,21 @@ export class IssueReporter extends Disposable {
this.renderBlocks();
}
setInitialFocus() {
const { fileOnExtension } = this.issueReporterModel.getData();
if (fileOnExtension) {
const issueTitle = document.getElementById('issue-title');
if (issueTitle) {
issueTitle.focus();
}
} else {
const issueType = document.getElementById('issue-type');
if (issueType) {
issueType.focus();
}
}
}
private applyZoom(zoomLevel: number) {
webFrame.setZoomLevel(zoomLevel);
browser.setZoomFactor(webFrame.getZoomFactor());